Ios 如何删除GCM&;SSL错误
我将GCM集成到我的应用程序中,代码如下:Ios 如何删除GCM&;SSL错误,ios,ssl,google-cloud-messaging,cfnetwork,Ios,Ssl,Google Cloud Messaging,Cfnetwork,我将GCM集成到我的应用程序中,代码如下: import UIKit import GoogleMaps import FBSDKLoginKit @available(iOS 9.0, *) @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate, GGLInstanceIDDelegate, GCMReceiverDelegate { var window: UIWindow? var connec
import UIKit
import GoogleMaps
import FBSDKLoginKit
@available(iOS 9.0, *)
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, GGLInstanceIDDelegate, GCMReceiverDelegate {
var window: UIWindow?
var connectedToGCM = false
var gcmSenderID: String?
var registrationOptions = [String: AnyObject]()
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
var configureError:NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
assert(configureError == nil, "Error configuring Google services: \(configureError)")
gcmSenderID = GGLContext.sharedInstance().configuration.gcmSenderID
application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil))
application.registerForRemoteNotifications()
let gcmConfig = GCMConfig.defaultConfig()
gcmConfig.receiverDelegate = self
GCMService.sharedInstance().startWithConfig(gcmConfig)
if(launchOptions?[UIApplicationLaunchOptionsLocationKey] != nil){
LocationService.sharedInstance.startMonitoringLocation()
}
return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
let instanceIDConfig = GGLInstanceIDConfig.defaultConfig()
instanceIDConfig.delegate = self
GGLInstanceID.sharedInstance().startWithConfig(instanceIDConfig)
let registrationOptions = [kGGLInstanceIDRegisterAPNSOption:deviceToken,
kGGLInstanceIDAPNSServerTypeSandboxOption:true]
GGLInstanceID.sharedInstance().tokenWithAuthorizedEntity(gcmSenderID,
scope: kGGLInstanceIDScopeGCM, options: registrationOptions, handler: registrationHandler)
}
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
print(userInfo)
completionHandler(UIBackgroundFetchResult.NewData)
}
func applicationDidEnterBackground(application: UIApplication) {
GCMService.sharedInstance().disconnect()
connectedToGCM = false
LocationService.sharedInstance.restartMonitoringLocation()
}
func applicationDidBecomeActive(application: UIApplication) {
GCMService.sharedInstance().connectWithHandler({(error:NSError?) -> Void in
if let error = error {
print("Could not connect to GCM: \(error.localizedDescription)")
} else {
self.connectedToGCM = true
print("Connected to GCM")
}
})
FBSDKAppEvents.activateApp()
}
func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
LocationService.sharedInstance.startUpdatingLocationTerminate()
}
func onTokenRefresh() {
// A rotation of the registration tokens is happening, so the app needs to request a new token.
print("The GCM registration token needs to be changed.")
GGLInstanceID.sharedInstance().tokenWithAuthorizedEntity(gcmSenderID,
scope: kGGLInstanceIDScopeGCM, options: registrationOptions, handler: registrationHandler)
}
func registrationHandler(registrationToken: String!, error: NSError!) {
if (registrationToken != nil) {
Gideon.notifId = registrationToken
print("GCM token: \(registrationToken)")
} else {
print("Registration to GCM failed with error: \(error.localizedDescription)")
}
}
这是我的日志:
2016-04-25 22:57:41.805 TestApp[2044:]应用程序测量
v、 2003000开始2016-04-25 22:57:41.805测试PP[2044:]到
启用调试日志记录设置以下应用程序参数:
-GMRDebugEnabled 2016-04-25 22:57:41.848:GCM | GCM库版本1.1.4 2016-04-25 22:57:41.868:GCM |无效
输入签入密码:GMSInstancedDeviceDataVersion GCM令牌:
k6uFlJWBSEg:APA91bGASVNpk-TWGTURFP8BSVCCFMPKTVLIG7MS6TCWNP4NVB26O3ZDFVLU6OQE1DTJOFAISISI6DZFU_Tt_P5C4V16;带7KZCQ0HNIZKEABHx0mg-2uzkJIkg-PVMPOHSBMTXYVG
2016-04-25 22:57:42.331 TestApp[2044:]应用程序测量
已启用2016-04-25 22:58:44.642 TestApp[2044:414848]CFNetwork
SSLHandshake失败(-9806)2016-04-25 22:59:13.425
TestApp[2044:414848]CFNetwork SSLHandshake失败(-9806)2016-04-25
22:59:34.918 Gideon[2044:414848]CFNetwork SSLHandshake失败(-9806)
已连接到GCM 2016-04-25 23:09:54.593 TestApp[2044:414848]CFNetwork
SSLHandshake失败(-9806)2016-04-25 23:10:08.681
TestApp[2044:414848]CFNetwork SSLHandshake失败(-9806)2016-04-25
23:10:27.482 TestApp[2044:414848]CFNetwork SSLHandshake失败(-9806)
无法连接到GCM:操作无法完成。
(com.google.gcm错误2001)
如何修复这些错误:
GCM |签入列表中的密钥无效:GMSInstanceIDDeviceDataVersion
CFNetwork SSLHandshake失败(-9806)
无法连接到GCM:操作无法完成。
(com.google.gcm错误2001)
提前感谢这与您的问题有关吗?不,我的通知工作正常我只想删除那些警告这与你的问题有关吗?不,我的通知工作正常我只想删除那些警告