迅速使用未声明的类型'GGLInstanceIDDelegate' [英] Swift Use of undeclared type 'GGLInstanceIDDelegate'

查看:106
本文介绍了迅速使用未声明的类型'GGLInstanceIDDelegate'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Google Cloud Messaging应用到我的iOS应用中。
但是我一直收到错误

I am trying to implement Google Cloud Messaging into my iOS app. But I keep getting the error


使用未声明的类型'GGLInstanceIDDelegate'

Use of undeclared type 'GGLInstanceIDDelegate'

我一直遵循Google支持页面上的说明,但无济于事。我的代码如下所示:

I have been following the instructions on Google's support pages but to no avail. My code looks like:

import UIKit

@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate, GGLInstanceIDDelegate {

    var window: UIWindow?

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        var osV = String(getMajorSystemVersion())

        if osV == "7"
        {
            UIApplication.sharedApplication().registerForRemoteNotificationTypes(UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound | UIRemoteNotificationType.Alert)
        }
        else if osV == "8"
        {
            // Register for remote notifications
            var types: UIUserNotificationType = UIUserNotificationType.Badge | UIUserNotificationType.Alert | UIUserNotificationType.Sound
            var settings: UIUserNotificationSettings = UIUserNotificationSettings( forTypes: types, categories: nil )
            application.registerUserNotificationSettings( settings )
            application.registerForRemoteNotifications()
        }

/* All the line below are throwing a similar error */  //GGLInstanceID.sharedInstance().startWithConfig(GGLInstanceIDConfig.defaultConfig())
//registrationOptions = [kGGLInstanceIDRegisterAPNSOption:deviceToken, kGGLInstanceIDAPNSServerTypeSandboxOption:true]
//GGLInstanceID.sharedInstance().tokenWithAuthorizedEntity(gcmSenderID, scope: kGGLInstanceIDScopeGCM, options: registrationOptions, handler: registrationHandler)

        return true
    }

我正在进入我的类声明中:

I am getting in my class declaration:

@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate, GGLInstanceIDDelegate {

有没有人有过这方面的成功?我将不胜感激任何帮助。我认为它与链接或类似的东西有关。

Has anybody had success with this? I would appreciate any help. I think it has to do with the linking or something like that.

推荐答案

您必须在Xcode Build中设置Bridging Header Swift Compiler Generation - >Objective-C Bridging Header下的设置如下所示:

You have to set the Bridging Header in the Xcode Build Settings under "Swift Compiler Generation" -> "Objective-C Bridging Header" like this:

"$(SRCROOT)/$(PROJECT_NAME)/ObjCBridgingHeader.h"

这篇关于迅速使用未声明的类型'GGLInstanceIDDelegate'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆