flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

🐛 [firebase_messaging]: The device has been locked and the silent push notification received at that time iOS app is getting crashed.

Open VishaliOSRapidops opened this issue 5 months ago • 9 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues.

Are you aware of the differences between iOS and Android background message handling?

  • [X] I understand that iOS and Android background messages behave differently, and I've designed my application with that in mind.

Do you have an active Apple Developer account?

  • [X] I have an active Apple Developer account.

Are you using a physical iOS device to test background messages?

  • [X] I am using a physical iOS device to test background messages.

Have you enabled "Remote Notifications" & "Background Mode" (Checking options for "Background Processing" & "Remote Notifications") in your app's Xcode project?

Screenshot 2024-03-15 at 8 10 42 PM

Have you created an APNs key in your Apple Developer account & uploaded this APNs key to your Firebase console?

Screenshot 2024-03-16 at 12 32 04 AM

Have you disabled method swizzling for Firebase in your app?

Screenshot 2024-03-15 at 9 38 51 PM

It doesn't matter whether it is or not.

Are you sending messages to your app from the Firebase Admin SDK?

{ "to": "token", "content_available": true, "priority":"high", "data": { "badge": "1", "alertUser": "true", "title": "Hello World", "message": "" } }

Have you requested permission from the user to receive notifications?

  • [X] I have the relevant permission to receive notifications.

Have you used the 'Console' application on your macOS device to check if the iOS device's system is throttling your background messages?

default	00:44:05.096307+0530	dasd	Hit the server for a process handle 1e48633d00001c6e that resolved to: [app<io.flutter.plugins.firebase.messaging(ADFBBE38-C6FE-4506-9FCF-08208AD0B913)>:7278]
default	00:44:05.096385+0530	dasd	Received state update for 7278 (app<io.flutter.plugins.firebase.messaging(ADFBBE38-C6FE-4506-9FCF-08208AD0B913)>, running-active-NotVisible
default	00:44:05.106244+0530	dasd	Trigger: <private> is now [1]
default	00:44:05.183360+0530	dasd	Received state update for 7278 (app<io.flutter.plugins.firebase.messaging(ADFBBE38-C6FE-4506-9FCF-08208AD0B913)>, running-active-NotVisible
default	00:44:06.365258+0530	dasd	Received state update for 434 (app<com.apple.InCallService(ADFBBE38-C6FE-4506-9FCF-08208AD0B913)>, running-active-NotVisible
default	00:44:07.377595+0530	dasd	Attempting to suspend based on triggers: (     "com.apple.duetactivityscheduler.pluggedinpolicy.batteryStatus",     "com.apple.duetactivityscheduler.restartpolicy.assertionsheld",     "com.apple.das.restartpolicy.backlightOn",     "com.apple.duetactivityscheduler.deviceactivitypolicy.inusestatus",     "Network Synchronization Policy",     "com.apple.duetactivityscheduler.restartpolicy.inusestatus" )
default	00:44:07.377634+0530	dasd	Ignoring trigger com.apple.duetactivityscheduler.pluggedinpolicy.batteryStatus because conditions are deteriorating
default	00:44:07.377676+0530	dasd	Ignoring trigger com.apple.duetactivityscheduler.restartpolicy.assertionsheld because conditions are deteriorating
default	00:44:07.377713+0530	dasd	Ignoring trigger com.apple.das.restartpolicy.backlightOn because conditions are deteriorating
default	00:44:07.377753+0530	dasd	Ignoring trigger com.apple.duetactivityscheduler.deviceactivitypolicy.inusestatus because conditions are deteriorating
default	00:44:07.377790+0530	dasd	Ignoring trigger Network Synchronization Policy because conditions are deteriorating
default	00:44:07.377825+0530	dasd	Ignoring trigger com.apple.duetactivityscheduler.restartpolicy.inusestatus because conditions are deteriorating
default	00:44:07.377860+0530	dasd	Evaluating 0 activities based on triggers
default	00:44:07.713819+0530	dasd	Submitted Activity: com.apple.pushLaunch.io.flutter.plugins.firebase.messaging:DDED87 at priority 5 (Sat Mar 16 00:44:07 2024 - Sun Mar 17 00:44:07 2024)
default	00:44:07.716233+0530	dasd	Adding a launch request (<private>) for application <private> by activity <private>
default	00:44:07.716268+0530	dasd	Launch requests for <private>: (null)
default	00:44:07.716389+0530	dasd	With <private> ...Tasks pre-running in group [com.apple.dasd.defaultNetwork] are 1!
default	00:44:07.717041+0530	dasd	Received state update for 434 (app<com.apple.InCallService(ADFBBE38-C6FE-4506-9FCF-08208AD0B913)>, running-active-Visible
default	00:44:07.719644+0530	dasd	com.apple.pushLaunch.io.flutter.plugins.firebase.messaging:DDED87:[
default	00:44:07.719685+0530	dasd	Activity com.apple.pushLaunch.io.flutter.plugins.firebase.messaging launch reason com.apple.das.launchreason.push is not a BGTask reason. Allowing background launch.
default	00:44:07.719754+0530	dasd	Activity: <private> requesting launch of application: <private>
default	00:44:07.719902+0530	dasd	With <private> ...Tasks pre-running in group [com.apple.dasd.defaultNetwork] are 1!
default	00:44:07.722196+0530	dasd	Launching with FBSOpenApplicationService for application <private>
default	00:44:07.722367+0530	dasd	[FBSSystemService][0xd777] Sending request to open "io.flutter.plugins.firebase.messaging"
default	00:44:07.727646+0530	SpringBoard	[FBSystemService][0xd777] Received request to open "io.flutter.plugins.firebase.messaging" from dasd:6325.
default	00:44:07.727739+0530	SpringBoard	[FBSystemService][0xd777] Trusting entitled client dasd:6325.
default	00:44:07.727780+0530	SpringBoard	Received trusted open application request for "io.flutter.plugins.firebase.messaging" from <FBProcess: 0x9a2c0ac90; osservice<com.apple.dasd>:6325(v45BB)>.
default	00:44:07.750614+0530	SpringBoard	Executing request: <SBMainWorkspaceTransitionRequest: 0x283337160; eventLabel: OpenApplication(sceneID:io.flutter.plugins.firebase.messaging-default)ForRequester(dasd.6325); display: Main; source: FBSystemService>
default	00:44:07.763715+0530	SpringBoard	Executing suspended-activation immediately: OpenApplication(sceneID:io.flutter.plugins.firebase.messaging-default)ForRequester(dasd.6325)
default	00:44:07.763752+0530	SpringBoard	[FBWorkspaceEvent] Executing: <FBWorkspaceEvent: 0x28055d9e0; OpenApplication(sceneID:io.flutter.plugins.firebase.messaging-default)ForRequester(dasd.6325)>
default	00:44:07.763788+0530	SpringBoard	[FBWorkspaceEvent] Executing: <FBWorkspaceEvent: 0x28055eac0; OpenApplication(sceneID:io.flutter.plugins.firebase.messaging-default)ForRequester(dasd.6325)>
default	00:44:07.767867+0530	dasd	[FBSSystemService][0xd777] Request successful: <BSProcessHandle: 0xeb8b20df0; CallTestApp:7278; valid: YES>
default	00:44:07.767904+0530	dasd	Process: <private>, Error: (null)
default	00:44:07.768007+0530	dasd	With <private> ...Tasks running in group [com.apple.dasd.defaultNetwork] are 1!
default	00:44:07.769761+0530	runningboardd	Acquiring assertion targeting [app<io.flutter.plugins.firebase.messaging(ADFBBE38-C6FE-4506-9FCF-08208AD0B913)>:7278] from originator [osservice<com.apple.dasd>:6325] with description <RBSAssertionDescriptor| "com.apple.das.backgroundFetch" ID:32-6325-122400 target:7278 attributes:[
	<RBSDomainAttribute| domain:"com.apple.dasd" name:"BackgroundDownload" sourceEnvironment:"(null)">
default	00:44:07.770947+0530	dasd	Assertion <private> acquired for task <private>
default	00:44:07.776751+0530	dasd	Received state update for 7278 (app<io.flutter.plugins.firebase.messaging(ADFBBE38-C6FE-4506-9FCF-08208AD0B913)>, running-active-NotVisible
default	00:44:07.787267+0530	symptomsd	SymptomAnalytics ServiceImpl: FAE perform query for dasd (pid 6325) on LiveUsage predicate hasProcess.bundleName IN {"io.flutter.plugins.firebase.messaging"} sort (null) actions {
default	00:44:08.363604+0530	dasd	Did invalidate assertion <private>
default	00:44:08.363639+0530	dasd	Calling invalidation handler for assertion <private>, server-initiated: YES
default	00:44:08.407701+0530	dasd	Received state update for 7278 (app<io.flutter.plugins.firebase.messaging(ADFBBE38-C6FE-4506-9FCF-08208AD0B913)>, none-NotVisible
error	00:44:08.409451+0530	dasd	Data type not yet set for stream APRSBiomeAppKillEvent, please switch to APIs that take eventDataClass as a parameter.
default	00:44:08.416100+0530	symptomsd	SymptomAnalytics ServiceImpl: FAE perform query for dasd (pid 6325) on LiveUsage predicate hasProcess.bundleName IN {"io.flutter.plugins.firebase.messaging"} sort (null) actions {
default	00:44:08.435273+0530	dasd	Data consumed for 0 for <private>
default	00:44:08.435308+0530	dasd	Calling completion
default	00:44:08.435661+0530	dasd	Running completion for app: <private> for activities: <private>
default	00:44:08.435775+0530	dasd	Running activities : <private>
default	00:44:08.435888+0530	dasd	With <private> ...Tasks running in group [com.apple.dasd.defaultNetwork] are 1!
default	00:44:08.437294+0530	dasd	COMPLETED com.apple.pushLaunch.io.flutter.plugins.firebase.messaging:DDED87 at priority 5 <private>!
default	00:44:08.437412+0530	dasd	NO LONGER RUNNING com.apple.pushLaunch.io.flutter.plugins.firebase.messaging:DDED87 ...Tasks running in group [com.apple.dasd.defaultNetwork] are 0!
default	00:44:08.437484+0530	dasd	Removing a launch request for application <private> by activity <private>
default	00:44:08.630628+0530	dasd	Received state update for 434 (app<com.apple.InCallService(ADFBBE38-C6FE-4506-9FCF-08208AD0B913)>, running-active-NotVisible
default	00:44:09.042649+0530	dasd	Received state update for 434 (app<com.apple.InCallService(ADFBBE38-C6FE-4506-9FCF-08208AD0B913)>, running-active-NotVisible
default	00:44:09.112926+0530	dasd	CANCELED: com.apple.duetexpertd.context-heuristic-refresh:C0A8B2 at priority 30 <private>!
default	00:44:09.113770+0530	dasd	Submitted Activity: com.apple.duetexpertd.context-heuristic-refresh:41CC0E at priority 30 (Sat Mar 16 02:36:11 2024 - Sat Mar 16 02:37:11 2024)
default	00:44:09.114228+0530	dasd	Activity <private>: Optimal Score 0.7595 at <private> (Valid Until: <private>)

Additional context and comments

In Android, it's working fine.

Steps to reproduce the issue in iOS,

(pre-condition)

  • The iOS app should be killed
  1. Lock the device
  2. Receive the VoIP incoming call
    • At the time of ringing VoIP call we are getting a silent push notification from our server with the payload of contentAvailable: true
    • File name: FLTFirebaseMessagingPlugin.m
    • As per the iOS guidelines flutter messaging package invoking the below method : - (BOOL)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler

The app is getting terminated when the below code is executed.

Screenshot 2024-03-19 at 7 00 24 PM

Thanks.

VishaliOSRapidops avatar Mar 15 '24 20:03 VishaliOSRapidops