大佬教程收集整理的这篇文章主要介绍了ios – Firebase(FCM)无法获取APNS令牌错误Domain = com.firebase.iid代码= 1001,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
在控制台,
无法获取APNS令牌错误Domain = com.firebase.iid代码= 1001“(null)”
以下是我的App Applegate代码
import UIKit import CoreData import Alamofire import Firebase import FirebaseInstancEID import Firebase@R_616_8798@ging @UIApplicationMain class AppDelegate: UIResponder,UIApplicationDelegate { var window: UIWindow? var badgeCount : Int = 0; enum BasicValidity : String { case success = "basicInfo" case Fail = "OauthAuthentificationError" } func application(application: UIApplication,didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. let uns: UIUserNotificationSetTings = UIUserNotificationSetTings(forTypes: [.Alert,.badge,.sound],categories: nil) application.registerUserNotificationSetTings(uns) application.registerForRemoteNotifications() FIRApp.configure() NsnotificationCenter.defaultCenter().addObserver(self,SELEctor: #SELEctor(self.tokenrefreshNotification),name: kFIRInstancEIDTokenrefreshNotification,object: nil) if let token = FIRInstancEID.instancEID().token() { sendTokenToServer(token) print("token is < \(token) >:") } return true } func application(application: UIApplication,didRegisterForRemoteNotificationsWithDeviCEToken deviCEToken: NSData){ print("didRegisterForRemoteNotificationsWithDeviCEToken()") // if FirebaseAppDelegateProxyEnabled === NO: FIRInstancEID.instancEID().setAPNSToken(deviCEToken,type: .SandBox) print("APNS: <\(deviCEToken)>") } func application(application: UIApplication,didFailToRegisterForRemoteNotificationsWithError error: NSError){ print("Registration for remote notification Failed with error: \(error.localizedDescription)") } func application(application: UIApplication,didReceiveRemoteNotification userInfo: [NSObject : AnyObject]){ print("didReceiveRemoteNotification()") //if FirebaseAppDelegateProxyEnabled === NO: FIR@R_616_8798@ging.@R_616_8798@ging().appDidReceive@R_616_8798@ge(userInfo) // handler(.NoData) } // [START refresh_token] func tokenrefreshNotification(notification: Nsnotification) { print("tokenrefreshNotification()") if let token = FIRInstancEID.instancEID().token() { print("InstancEID token: \(token)") sendTokenToServer(token) FIR@R_616_8798@ging.@R_616_8798@ging().subscribeToTopic("/topics/global") print("Subscribed to: /topics/global") } connectToFcm() } // [END refresh_token] func sendTokenToServer(currentToken: String) { print("sendTokenToServer() Token: \(currentToken)") // Send token to server ONLY IF NECESSARY } // [START connect_to_fcm] func connectToFcm() { FIR@R_616_8798@ging.@R_616_8798@ging().connectWithCompletion { (error) in if error != nil { print("Unable to connect with FCm. \(error!)") } else { print("Connected to FCm.") } } } // [END connect_to_fcm] func applicationWillResignActive(application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS @R_616_8798@gE) or when the user quits the application and it begins the transition to the BACkground state. // Use this method to pause ongoing tasks,disable timers,and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } // [START disconnect_from_fcm] func applicationDidEnterBACkground(application: UIApplication) { // Use this method to release shared resources,save user data,invalidate timers,and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports BACkground execution,this method is called instead of applicationWillTerminate: when the user quits. FIR@R_616_8798@ging.@R_616_8798@ging().disconnect() print("Disconnected from FCm.") } func applicationWillEnterForeground(application: UIApplication) { // Called as part of the transition from the BACkground to the inactive state; here you can undo many of the changes made on entering the BACkground. } func applicationDidBecomeActive(application: UIApplication) { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was prevIoUsly in the BACkground,optionally refresh the user interface. // UIApplication.sharedApplication().applicationIconBadgenumber = 0 connectToFcm() } func applicationWillTerminate(application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBACkground:. // Saves changes in the application's managed object context before the application terminates. self.saveContext() }
>如果我通过使用软件包ID发送通知,我可以从Firebase控制台获取通知.但是如果我们的服务器通过令牌将通知发送到特定设备,我无法得到.
以上是大佬教程为你收集整理的ios – Firebase(FCM)无法获取APNS令牌错误Domain = com.firebase.iid代码= 1001全部内容,希望文章能够帮你解决ios – Firebase(FCM)无法获取APNS令牌错误Domain = com.firebase.iid代码= 1001所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。