首页 > 解决方案 > 应用重启后未收到 FCM 通知

问题描述

问题:

一旦我们终止应用程序,我将面临一个未收到 FCM 通知的奇怪问题。我不确定出了什么问题。作为统一的 FCM SDK,将自动初始化并使用 FCM 门户/数据库注册令牌。每次我们开始游戏时,我们都会收到 FCM 令牌并将其更新到我们自己的服务器,以便稍后使用它来发送推送通知。

我们试图解决的问题。

我们尝试了基本的故障排除,例如更改 Unity 插件版本(我们尝试了 FCM Unity SDK v5.5.0 和 v5.6.0),使用了具有不同操作系统版本的不同 ios 设备。

我们还尝试从 unity3D 构建集“开发构建”选项(选中和未选中)。

重新启动应用程序后,我们不会在屏幕或日志控制台上收到任何与 FCM 相关的错误或警告。

在这里,我还从 XCode 日志控制台输入了日志(一些行被删除,因为它与其他代码和功能相关。

objc[2851]: Class CTBundle is implemented in both /System/Library/Frameworks/CoreTelephony.framework/CoreTelephony (0x21715a250) and /var/containers/Bundle/Application/5A10884A-144F-4E13-9410-38884935EBA0/the100k.app/the100k (0x107743ad0). One of the two will be used. Which one is undefined.
2019-04-04 12:22:53.273087+0530 theApp[2851:791775] [DYMTLInitPlatform] platform initialization successful
2019-04-04 12:22:53.326547+0530 theApp[2851:791628] FCM: Loading UIApplication FIRFCM category
2019-04-04 12:22:53.327074+0530 theApp[2851:791786]  - <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-04-04 12:22:53.439337+0530 theApp[2851:791628] Built from '2018.3/staging' branch, Version '2018.3.8f1 (fc0fe30d6d91)', Build type 'Development', Scripting Backend 'il2cpp'
2019-04-04 12:22:53.445243+0530 theApp[2851:791628] -> registered mono modules 0x107049330
2019-04-04 12:22:53.591994+0530 theApp[2851:791628] You've implemented -[<UIApplicationDelegate> application:didReceiveRemoteNotification:fetchCompletionHandler:], but you still need to add "remote-notification" to the list of your supported UIBackgroundModes in your Info.plist.
2019-04-04 12:22:53.592369+0530 theApp[2851:791628] Setting up iOS 10 message delegate.
-> applicationDidFinishLaunching()
PlayerConnection initialized from /var/containers/Bundle/Application/5A10884A-144F-4E13-9410-38884935EBA0/the100k.app/Data (debug = 0)
PlayerConnection initialized network socket : 0.0.0.0 55000
Multi-casting "[IP] 10.2.11.120 [Port] 55000 [Flags] 2 [Guid] 2502646412 [EditorId] 905987573 [Version] 1048832 [Id] iPhonePlayer(INIC-A006):56000 [Debug] 0 [PackageName] iPhonePlayer" to [225.0.0.222:54997]...
Started listening to [0.0.0.0:55000]
PlayerConnection already initialized - listening to [0.0.0.0:55000]
2019-04-04 12:22:53.663072+0530 theApp[2851:791628] Metal GPU Frame Capture Enabled
2019-04-04 12:22:53.664986+0530 theApp[2851:791628] Metal API Validation Disabled
2019-04-04 12:22:53.776618+0530 theApp[2851:791628] [Warning] Trying to set delaysTouchesBegan to NO on a system gate gesture recognizer - this is unsupported and will have undesired side effects
-> applicationDidBecomeActive()
GfxDevice: creating device client; threaded=1
Initializing Metal device caps: Apple A9 GPU
Initialize engine version: 2018.3.8f1 (fc0fe30d6d91)
UnloadTime: 0.610417 ms

2019-04-04 12:22:54.611049+0530 theApp[2851:791628] Identifier not mentions init with bundle id
2019-04-04 12:22:54.611380+0530 theApp[2851:791628] access group not mentions init no access group
2019-04-04 12:22:54.642489+0530 theApp[2851:791628] TransactionObserver added
2019-04-04 12:22:54.642879+0530 theApp[2851:791628] do we support downloads: YES
2019-04-04 12:22:54.643920+0530 theApp[2851:791628] will we defer store payments: NO
2019-04-04 12:22:54.649145+0530 theApp[2851:791628] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2019-04-04 12:22:54.650242+0530 theApp[2851:791628] [MC] Reading from public effective user settings.

Using Facebook Unity SDK v7.15.1 with FBiOSSDK/4.39.1
Facebook.Unity.CompiledFacebookLoader:Start()

(Filename: ./Runtime/Export/Debug.bindings.h Line: 45)

  Thread -> id: 16cca7000 -> priority: 1 
Unloading 5 Unused Serialized files (Serialized files now loaded: 0)
2019-04-04 12:22:54.980645+0530 theApp[2851:791848] 5.18.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:
https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging
to ensure proper integration.
2019-04-04 12:22:54.980687+0530 theApp[2851:791848] 5.18.0 - [Firebase/Analytics][I-ACS023007] Analytics v.50700000 started
2019-04-04 12:22:54.980703+0530 theApp[2851:791848] 5.18.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled


2019-04-04 12:22:55.077739+0530 theApp[2851:791628] FCM: new registration token received.
FCM: new registration token received.

(Filename: ./Runtime/Export/Debug.bindings.h Line: 45)

2019-04-04 12:22:55.078802+0530 theApp[2851:791628] FCM: Retrieve registration token
FCM: Retrieve registration token

(Filename: ./Runtime/Export/Debug.bindings.h Line: 45)

2019-04-04 12:22:55.102140+0530 theApp[2851:791858] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C1.1:2][0x10de1fba0] get output frames failed, state 8196
2019-04-04 12:22:55.102256+0530 theApp[2851:791858] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C1.1:2][0x10de1fba0] get output frames failed, state 8196
2019-04-04 12:22:55.102484+0530 theApp[2851:791858] TIC Read Status [1:0x0]: 1:57
2019-04-04 12:22:55.102526+0530 theApp[2851:791858] TIC Read Status [1:0x0]: 1:57
2019-04-04 12:22:55.130392+0530 theApp[2851:791628] [NetworkInfo] Signal strength query returned error: Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied", descriptor: <CTServiceDescriptor 0x280694c80, domain=1, instance=1>
2019-04-04 12:22:55.136398+0530 theApp[2851:791858] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C2.1:2][0x10df1a250] get output frames failed, state 8196
2019-04-04 12:22:55.136792+0530 theApp[2851:791858] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C2.1:2][0x10df1a250] get output frames failed, state 8196
2019-04-04 12:22:55.137102+0530 theApp[2851:791858] TIC Read Status [2:0x0]: 1:57
2019-04-04 12:22:55.137120+0530 theApp[2851:791858] TIC Read Status [2:0x0]: 1:57
2019-04-04 12:22:55.139681+0530 theApp[2851:791628] FCM: Initialize Firebase Messaging
FCM: Initialize Firebase Messaging

(Filename: ./Runtime/Export/Debug.bindings.h Line: 45)

2019-04-04 12:22:55.140171+0530 theApp[2851:791628] FCM: Using FCM senderID X76XX00XX22X
FCM: Using FCM senderID X76XX00XX22X

(Filename: ./Runtime/Export/Debug.bindings.h Line: 45)

2019-04-04 12:22:55.142519+0530 theApp[2851:791628] FCM: Retrieve registration token
FCM: Retrieve registration token

(Filename: ./Runtime/Export/Debug.bindings.h Line: 45)

2019-04-04 12:22:55.176769+0530 theApp[2851:791628] didRegisterForRemoteNotificationsWithDeviceToken: <ed5242cd 6711c0d2 04d8c1f4 97d9f4f8 414582b4 01eed9ad b256fe6f 38cf1076>
2019-04-04 12:22:55.209552+0530 theApp[2851:791628] didRegisterForRemoteNotificationsWithDeviceToken: <ed5242cd 6711c0d2 04d8c1f4 97d9f4f8 414582b4 01eed9ad b256fe6f 38cf1076>
2019-04-04 12:22:55.213322+0530 theApp[2851:791628] didRegisterForRemoteNotificationsWithDeviceToken: <ed5242cd 6711c0d2 04d8c1f4 97d9f4f8 414582b4 01eed9ad b256fe6f 38cf1076>
2019-04-04 12:22:55.216454+0530 theApp[2851:791628] didRegisterForRemoteNotificationsWithDeviceToken: <ed5242cd 6711c0d2 04d8c1f4 97d9f4f8 414582b4 01eed9ad b256fe6f 38cf1076>
System memory in use before: 34.8 MB.
System memory in use after: 35.1 MB.

Unloading 34 unused Assets to reduce memory usage. Loaded Objects now: 4406.
Total: 11.901000 ms (FindLiveObjects: 1.246375 ms CreateObjectMapping: 0.107042 ms MarkObjects: 8.864583 ms  DeleteObjects: 1.682167 ms)

[12:22:55.234] l: Token "cUxPw6jbQtg:APA91bFSeCvXMDXxcltzIvk2Ulas1Dq7gNjBNhsxNqPj5ZJNsBcZuB55TNf_dcG0J3gDHUyILMD6nEne-hCnnUUHEh9mj1yMoBlYtg4r1ixdcO2Rm3yYGUE73WQ6-G6hUm4MHLN1TY9u" is received from Firebase
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()

(Filename: ./Runtime/Export/Debug.bindings.h Line: 45)

Unloading 1 Unused Serialized files (Serialized files now loaded: 0)
System memory in use before: 34.7 MB.
System memory in use after: 35.0 MB.

Unloading 0 unused Assets to reduce memory usage. Loaded Objects now: 4406.
Total: 13.005333 ms (FindLiveObjects: 0.964000 ms CreateObjectMapping: 0.069500 ms MarkObjects: 11.943958 ms  DeleteObjects: 0.026875 ms)

2019-04-04 12:22:55.332752+0530 theApp[2851:791762] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C3.1:2][0x117e2c100] get output frames failed, state 8196
2019-04-04 12:22:55.333074+0530 theApp[2851:791762] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C3.1:2][0x117e2c100] get output frames failed, state 8196
2019-04-04 12:22:55.333290+0530 theApp[2851:791762] TIC Read Status [3:0x0]: 1:57
2019-04-04 12:22:55.333308+0530 theApp[2851:791762] TIC Read Status [3:0x0]: 1:57

2019-04-04 12:22:55.542556+0530 theApp[2851:791762] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C6.1:2][0x1175b48e0] get output frames failed, state 8196
2019-04-04 12:22:55.542677+0530 theApp[2851:791762] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C6.1:2][0x1175b48e0] get output frames failed, state 8196
2019-04-04 12:22:55.542895+0530 theApp[2851:791762] TIC Read Status [6:0x0]: 1:57
2019-04-04 12:22:55.542910+0530 theApp[2851:791762] TIC Read Status [6:0x0]: 1:57

2019-04-04 12:22:55.977707+0530 theApp[2851:791762] TIC TCP Conn Failed [8:0x283321e00]: 12:8 Err(-65554)
2019-04-04 12:22:55.979306+0530 theApp[2851:791858] Task <77C87314-C722-4E0F-95CA-77CFA8EEE5DE>.<2> HTTP load failed (error code: -1003 [12:8])
2019-04-04 12:22:55.979504+0530 theApp[2851:791858] Task <77C87314-C722-4E0F-95CA-77CFA8EEE5DE>.<2> finished with error - code: -1003

Unloading 0 Unused Serialized files (Serialized files now loaded: 0)
System memory in use before: 34.7 MB.
System memory in use after: 35.0 MB.

Unloading 0 unused Assets to reduce memory usage. Loaded Objects now: 4408.
Total: 10.983458 ms (FindLiveObjects: 0.875458 ms CreateObjectMapping: 0.081792 ms MarkObjects: 10.004875 ms  DeleteObjects: 0.020167 ms)

当前结果:

重新启动应用程序后,设备不会收到推送通知。

但是当 PHP 服务器代码执行向设备发送推送通知时,FCM API 将返回失败消息

{
    "multicast_id": X7XXX02XXX217XXX0X,
    "success": 0,
    "failure": 1,
    "canonical_ids": 0,
    "results": [{
        "error": "NotRegistered"
    }]
}

预期结果: 即使应用程序在后台模式或前台被杀死,它也应该始终发送推送通知。

标签: iosfirebaseunity3dfirebase-cloud-messaging

解决方案


推荐阅读