我重新編譯我的iOS9 iPhone應用程序和我越來越想爲GCM註冊時出現錯誤,如下注冊:GCM失敗與1003錯誤
登記GCM失敗,出現錯誤:操作不能完成。 (com.google.iid error 1003.)
我已經找了一段時間了,在Google上找不到任何東西。 任何人都可以幫助我嗎?
在此先感謝
從下面appdelegate.swift代碼:
var connectedToGCM = false
var subscribedToTopic = false
var gcmSenderID: String?
var registrationToken: String?
var registrationOptions = [String: AnyObject]()
let registrationKey = "onRegistrationCompleted"
let messageKey = "onMessageReceived"
let subscriptionTopic = "/topics/global"
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let settings: UIUserNotificationSettings =
UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)
application.registerUserNotificationSettings(settings)
application.registerForRemoteNotifications()
GCMService.sharedInstance().startWithConfig(GCMConfig.defaultConfig())
return true
}
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData)
{
//Process the deviceToken and send it to your server
let tokenChars = UnsafePointer<CChar>(deviceToken.bytes)
var tokenString = ""
for var i = 0; i < deviceToken.length; i++
{
tokenString += String(format: "%02.2hhx", arguments: [tokenChars[i]])
}
GGLInstanceID.sharedInstance().startWithConfig(GGLInstanceIDConfig.defaultConfig())
registrationOptions = [kGGLInstanceIDRegisterAPNSOption:deviceToken,
kGGLInstanceIDAPNSServerTypeSandboxOption:true]
GGLInstanceID.sharedInstance().tokenWithAuthorizedEntity(gcmSenderID, scope: kGGLInstanceIDScopeGCM, options: registrationOptions, handler: registrationHandler)
}
func registrationHandler(registrationToken: String!, error: NSError!)
{
if (registrationToken != nil)
{
self.registrationToken = registrationToken
print("Registration Token: \(registrationToken)")
APIManager.sharedInstance.setDeviceToken(registrationToken)
self.subscribeToTopic()
let userInfo = ["registrationToken": registrationToken]
NSNotificationCenter.defaultCenter().postNotificationName(
self.registrationKey, object: nil, userInfo: userInfo)
}
else
{
print("Registration to GCM failed with error: \(error.localizedDescription)")
let userInfo = ["error": error.localizedDescription]
NSNotificationCenter.defaultCenter().postNotificationName(
self.registrationKey, object: nil, userInfo: userInfo)
}
}
我們能看到一些代碼嗎?可能有助於診斷問題。 –
我已添加代碼 – Luben