简体   繁体   中英

Swift Use of undeclared type 'GGLInstanceIDDelegate'

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

Use of undeclared type 'GGLInstanceIDDelegate'

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 Settings中的“ Swift Compiler Generation”->“ Objective-C Bridging Header”下设置桥接头,如下所示:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM