Выпуск:
Я сталкиваюсь со странной проблемой, когда уведомление FCM не получено, как только мы убиваем приложение. Я не уверен, что происходит не так. Как FCM SDK для единицы, будет инициализировать автоматически и зарегистрировать токен на портале / базе данных FCM. Каждый раз, когда мы запускаем игру, мы получаем токен FCM и обновляем его на своем собственном сервере, чтобы позже использовать его для отправки Push-уведомления.
Что мы пытались решить проблему.
Мы пробовали в основном устранять неполадки, такие как изменение версии плагина Unity (мы пробовали FCM Unity SDK v5.5.0 и v5.6.0), использовали разные устройства ios с другой версией ОС.
Мы также пытались «развернуть сборку» (проверено и не проверено) из набора Unity3D Build.
После перезапуска приложения мы не получаем никаких ошибок или предупреждений, связанных с 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)
Текущий результат:
Нет push-уведомлений на устройство после перезапуска приложения.
Но когда исполняется код сервера PHP для отправки push-уведомления на устройство, API FCM вернет ошибку с сообщением
{
"multicast_id": X7XXX02XXX217XXX0X,
"success": 0,
"failure": 1,
"canonical_ids": 0,
"results": [{
"error": "NotRegistered"
}]
}
Ожидаемый результат:
Всегда следует отправлять push-уведомления, даже если приложение убито, в фоновом режиме или на переднем плане.