0

我正在为 iOS 集成 google instance id api,并调用如下适当的方法来获取实例 id。

 let gcmConfig = GCMConfig.defaultConfig()
    gcmConfig.receiverDelegate = self
    GCMService.sharedInstance().startWithConfig(gcmConfig)

GGLInstanceID.sharedInstance().getIDWithHandler { (identity, error) -> Void in if let err = error { print(err) } else{ self.instanceID = identity } }

但是我收到了这个错误

Error Domain=com.google.iid Code=1005 "(null)"

我遵循了这个 url上的文档

任何帮助将不胜感激。

4

1 回答 1

3

您找到解决问题的方法了吗?

我遇到了同样的错误,我想通了。这是 Obj-C 代码,但我认为它在 swift 中是相同的。问题是配置初始化。

GGLInstanceIDConfig *config = [GGLInstanceIDConfig defaultConfig];
[[GGLInstanceID sharedInstance] startWithConfig:config];
GGLInstanceID *iidInstance = [GGLInstanceID sharedInstance];

GGLInstanceIDHandler handler = ^void(NSString *identity, NSError *error) {
    if (error) {
        NSLog(@"error %@", [error description]);
    } else {
        // handle InstanceID for the app
       NSLog(@"Success! ID = %@", identity);
 }

[iidInstance getIDWithHandler:handler];
于 2016-03-14T11:08:46.697 回答