firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.51k stars 3.92k forks source link

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

Open VishaliOSRapidops opened 3 months ago

VishaliOSRapidops commented 3 months ago

Is there an existing issue for this?

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

Do you have an active Apple Developer account?

Are you 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?

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)

  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 commented 3 months ago

@russellwheatley @Salakar @Lyokone I've manually downloaded the plugin and integrated it into my app by removing the above-mentioned code snippet, it is working fine. But don't know why that code block is creating an issue.

russellwheatley commented 3 months ago

@VishaliOSRapidops - so I understand, you are receiving a VoIP call from some other service, when that call is occuring on the device, you also send a background message via some Firebase admin API service which crashes the background process for pushing the message?

Could you provide a full reproduction so we can test, ideally a repository with clear steps on reproduction. Thank you.

VishaliOSRapidops commented 3 months ago

@russellwheatley Thanks for your prompt reply, Yes, you understand the same. We are using Twilio for VoIP calls so it has several configuration parts, and that is not possible to share. I am ready to connect with your preferred communication channel, so I can explain you everything in detail.

VishaliOSRapidops commented 3 months ago

@russellwheatley @Salakar @Lyokone https://github.com/firebase/flutterfire/assets/71368703/45911392-63bb-4340-bac9-d7eb63ea3b9a

As you can see in the video, When I received the VoIP call on the lock screen suddenly the app is terminated.

Technical details: Incoming call received through Twilio VoIP at the same time as per our requirement we are getting silent notification, Whenever receive the silent notification app is suddenly terminated.

It is my production blocker, Kindly please help. Thank you.

VishaliOSRapidops commented 3 months ago

@russellwheatley is there any update?

russellwheatley commented 3 months ago

There is no update I'm afraid, @VishaliOSRapidops. We prioritise issues with reproductions and there isn't one for this issue which would require significant time to setup. Please provide a reproduction repo and we can take a look. You don't have to provide your config values but please provide steps to setup any third party providers that appear to be a requirement (e.g. Twilio).

VishaliOSRapidops commented 3 months ago

@russellwheatley I've invited you for the reproduction repo. Here are the steps to follow:

  1. You need to create accessToken from Twilio using the steps which are mentioned in this https://www.twilio.com/docs/voice/sdks/ios/get-started

  2. Go the repo-> example -> lib -> main.dart, here you need to initialize the Firebase setup using your config.

  3. In the main.dart file you need to pass accessToken in this registerAccessTokenForIncomingCall() method.

VishaliOSRapidops commented 3 months ago

@russellwheatley are you able to reproduce the issue on that repo that I've invited to you?

VishaliOSRapidops commented 2 months ago

@russellwheatley any update on this issue or do you need any more stuff to reproduce? please help me this is a production blocker.