Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么可以';我在iOS 11.4版中获取设备令牌值和FCM令牌值吗?_Ios_Swift_Firebase_Firebase Cloud Messaging - Fatal编程技术网

为什么可以';我在iOS 11.4版中获取设备令牌值和FCM令牌值吗?

为什么可以';我在iOS 11.4版中获取设备令牌值和FCM令牌值吗?,ios,swift,firebase,firebase-cloud-messaging,Ios,Swift,Firebase,Firebase Cloud Messaging,我正在通过FCM开发消息通信 但是有个问题。在iphone6版本12.4上,您通常可以获取设备令牌和FCM值 但是,11.4不获取设备令牌值,也不获取FCM令牌值。我不知道是什么问题 AppDelegate.swift 导入UIKit 导入用户通知 进口火基 导入FirebaseMessaging @UIApplicationMain 类AppDelegate:UIResponder、UIApplicationLegate、UnuseNotificationCenterDelegate、Mess

我正在通过FCM开发消息通信

但是有个问题。在
iphone6
版本
12.4
上,您通常可以获取设备令牌和FCM值

但是,
11.4
不获取设备令牌值,也不获取FCM令牌值。我不知道是什么问题

AppDelegate.swift

导入UIKit
导入用户通知
进口火基
导入FirebaseMessaging
@UIApplicationMain
类AppDelegate:UIResponder、UIApplicationLegate、UnuseNotificationCenterDelegate、MessagingDelegate{
func注册表AppForPushNotification(){
如果可用(iOS 10.0,*){
let center=UNUserNotificationCenter.current()
让inviteCategory=UNNotificationCategory(标识符:“通知”,操作:[],意图标识符:[],选项:UNNotificationCategoryOptions.customDismissAction)
let categories=NSSet(对象:invitecategority)
center.delegate=self
center.setNotificationCategories(类别为!集)
requestAuthorization(选项:[.sound、.badge、.alert],completionHandler:{(已授予,错误)在中
如果!(错误!=nil){
DispatchQueue.main.async(执行:{
UIApplication.shared.registerForRemoteNotifications()
})
}
})
}否则{
UIApplication.shared.registerUserNotificationSettings(UIUserNotificationSettings(类型:[.sound、.alert、.badge],类别:nil))
UIApplication.shared.registerForRemoteNotifications()
}
}
@可用(iOS 10.0,*)
func userNotificationCenter(center:UNUserNotificationCenter,
将提交通知:未通知,
withCompletionHandler completionHandler:@escaping(UNNotificationPresentationOptions)->Void)
{
completionHandler(.alert)
}
func应用程序(application:UIApplication,didFinishLaunchingWithOptions launchOptions:[UIApplication.launchOptions键:任意]?)->Bool{
self.window=UIWindow(框架:UIScreen.main.bounds)
//应用程序启动后自定义的覆盖点。
//创建通知中心
Messaging.Messaging().delegate=self
FirebaseApp.configure()
//为推送通知注册应用程序
let center=UNUserNotificationCenter.current()
让inviteCategory=UNNotificationCategory(标识符:“通知”,操作:[],意图标识符:[],选项:UNNotificationCategoryOptions.customDismissAction)
let categories=NSSet(对象:invitecategority)
center.delegate=self
center.setNotificationCategories(类别为!集)
DispatchQueue.main.async(执行:{
UIApplication.shared.registerForRemoteNotifications()
})
应用程序.注册表项更改()
}
func应用程序(application:UIApplication,DidRegisterForRemotionTificationswithDeviceToken deviceToken:Data){
让token=deviceToken.map{String(格式:'%02x',$0)}.joined()
Log.Info(“注册成功!”)
Log.Info(“令牌:\(令牌)”)
Auth.Auth().setAPNSToken(deviceToken,类型:AuthAPNSTokenType.sandbox)
Messaging.Messaging().apnsToken=deviceToken
InstanceID.InstanceID().InstanceID{(结果,错误)位于
如果let error=error{
Log.Error(“获取远程实例ID时出错:\(错误)”)
}如果let result=result,则为else{
Log.Info(“远程实例ID令牌:\(result.token)”)
LocalStorage.set(result.token,“dacDeviceToken”)
}
}
Messaging.Messaging().shouldEstablishDirectChannel=true
}
func应用程序(应用程序:UIApplication,DidRegisterForRemotionTificationswithDeviceToken deviceToken:NSData){
Messaging.Messaging().apnsToken=deviceToken为数据
//打印(deviceToken)
}
func应用程序(application:UIApplication,DidFailToRegister for RemoteNotifications,错误:error){
日志。警告(“注册失败!”)
}
func应用程序(application:UIApplication,DidReceiveMemotentification用户信息:[AnyHashable:Any],
fetchCompletionHandler completionHandler:@escaping(UIBackgroundFetchResult)->Void{
如果Auth.Auth().canHandleNotification(userInfo){
Log.Info(“fetchCompletionHandler”)
completionHandler(UIBackgroundFetchResult.noData)
返回
}
Log.Info(“fetchCompletionHandler”)
completionHandler(UIBackgroundFetchResult.newData)
}
func消息传递(u消息传递:消息传递,didReceiveRegistrationToken fcmToken:String){
Log.Info(“fcmToken\(fcmToken)”)
}
func消息传递(uMessaging:messaging,didReceive remoteMessage:MessagingRemoteMessage){
Log.Info(“remort\(remoteMessage.appData)”)
}
func应用程序WillResignActive(application:UIApplication){
//当应用程序即将从活动状态移动到非活动状态时发送。这可能发生在某些类型的临时中断(如来电或短信)或用户退出应用程序并开始转换到后台状态时。
//使用此方法暂停正在进行的任务、禁用计时器和使图形渲染回调无效。游戏应使用此方法暂停游戏。
Log.Info(“applicationWillResignActive”)
}
func应用程序标识符背景(u应用程序:UIApplication){
//使用此方法释放共享资源、保存用户数据、使计时器无效,并存储足够的应用程序状态信息,以便在应用程序稍后终止时将其恢复到当前状态。
# Pods for DeleteMe
pod 'SwiftSVG', '~> 2.0'
pod 'Toaster'
pod 'BigInt', '~> 4.0'
pod 'CryptoSwift'
pod 'RealmSwift'
pod 'web3.swift.pod', '~> 2.2.0'
pod 'Firebase'
pod 'Firebase/Messaging'
pod 'Firebase/Auth'
2019-10-02 13:39:01.964008+0900 test[1804:476574]  - <AppMeasurement>[I-ACS036002] Analytics screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist
2019-10-02 13:39:02.045557+0900 test[1804:476574] 6.9.0 - [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your application initialization. Read more:
2019-10-02 13:39:02.099986+0900 test[1804:476574] 6.9.0 - [Firebase/Analytics][I-ACS023007] Analytics v.60102000 started
2019-10-02 13:39:02.102201+0900 test[1804:476574] 6.9.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled 
2019-10-02 13:39:02.139092+0900 test[1804:476582] 6.9.0 - [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow the instructions at:
to ensure proper integration.
2019-10-02 13:39:02.231208+0900 test[1804:476536] [Graphics] UIColor created with component values far outside the expected range. Set a breakpoint on UIColorBreakForOutOfRangeColorComponents to debug. This message will only be logged once.
INFO: 2019-10-02 04:39:02 +0000 - <UI> AppDelegate.swift applicationDidBecomeActive(_:) [Line:225] 
applicationDidBecomeActive
2019-10-02 13:39:02.371104+0900 test[1804:476581] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2019-10-02 13:39:02.373237+0900 test[1804:476581] [MC] Reading from public effective user settings.