iOS Question Firebase notification crash app.

janderkan

Well-Known Member
Licensed User
Longtime User
My App uses FCM and MQTT.
The App works fine in both debug and release mode and I have created a testflight with no problems.
The problem only shows in release mode and only in one case:
My phone is locked and screen off.
After a while when the App has been killed, I receive a firebase notification.
The screen turns on, i press the notification and enter password to unlock phone.
Main screen of my App is visible and within less than a second the App crashes.
I use iReleaseLogger, have a log statement and a try catch in every sub, but nothing in the log.
Now I am stuck, I have tried to include the dSYM, but then my App will not compile. (Attached error.txt)
 

Attachments

  • error.txt
    150.4 KB · Views: 310

janderkan

Well-Known Member
Licensed User
Longtime User
dSYM will not help here.

Are you using a local Mac?

No I am using the hosted builder.
I have some of my subs compiled in a lib, will try catch and log work with iReleaselogger?

Should I try to include the subs in my project?

If I receive the notification and wait until it disappears, then I can open my App with no problem.
So it looks as the problem shows, when data is transfered to Application_RemoteNotification

Is it possible that the notification itself contains something that give this problem?

Last update:
I test 2 devices, iPhone6 and iPhone7
1.
I doubleclick the button and swipe up to remove the App.
Receives FCM.
Open the App and everything works fine.
2.
I close the phone with 1 tap on power button and wait 3 minutes.
Receives FCM.
Open the App and it crashes, no error and nothing in the iReleaselogger.

This is consistent.
 
Last edited:
Upvote 0

janderkan

Well-Known Member
Licensed User
Longtime User
What happens if you comment the code in Application_RemoteNotification?

Exactly the same, this is the only code:
B4X:
Private Sub Application_RemoteNotification (Message As Map, CompletionHandler As CompletionHandler)
    Log($"Message arrived: ${Message}"$)
    CompletionHandler.Complete
End Sub

There are no data in the notification.
B4X:
{
  "notification": {
    "sound": "a1.wav",
    "alert": "true",
    "badge": 0,
    "title": "Light test",
    "body": "Slukket"
  },
  "collapse_key": "dti",
  "to": "\/topics\/ios_25031-10000-5C_CF_7F_21_FD_66-0",
  "priority": 10,
  "data": {
  }
}
 
Upvote 0

janderkan

Well-Known Member
Licensed User
Longtime User
Now I have started a new project, only with push notification.
Exactly the same result:(

This is the complete code:
B4X:
Sub Process_Globals
    Public App As Application
    Public NavControl As NavigationController

    Private analytics As FirebaseAnalytics
    Public fm As FirebaseMessaging

    Private Page As Page

    Dim rl As ReleaseLogger                    'Remember to remove !! (uses iNetwork)
End Sub

Private Sub Application_Start (Nav As NavigationController)
'        SetDebugAutoFlushLogs(True) 'Uncomment if program crashes before all logs are printed.
'        App.IdleTimerDisabled=True

    rl.Initialize("192.168.1.8", 54323)

    NavControl = Nav
    Page.Initialize("Main")
    Page.RootPanel.LoadLayout("1")
    Page.Title = "main_title"
    NavControl.ShowPage(Page)
    
    'Firebase
    analytics.Initialize
    App.RegisterUserNotifications(True, True, True)
    App.RegisterForRemoteNotifications
    fm.Initialize("fm")

    Log("App Start")   
End Sub

private Sub Application_Active
    fm.FCMConnect 'should be called from Application_Active
    Log("App Active")
End Sub

Private Sub Application_Background
    fm.FCMDisconnect 'should be called from Application_Background
    Log("App Background")
End Sub

private Sub Application_PushToken (Success As Boolean, Token() As Byte)
    Log("Pushtoken: " & Success)
End Sub

Private Sub fm_FCMConnected
    'here we can subscribe and unsubscribe from topics
    fm.SubscribeToTopic("ios_25031") 'add ios_ prefix to all topics
    Log("FCMConnected")
End Sub

Private Sub Application_RemoteNotification (Message As Map, CompletionHandler As CompletionHandler)
    Log($"Message arrived: ${Message}"$)
    CompletionHandler.Complete
End Sub
 
Upvote 0
Top