I have an App that IS WORKING with firebase it receive notifications. But I have a COUPLE of cases when a device never receive notifications, somethimes it crashes whith this error:
The problem is NOT about security or permissions, the app is working in most cases. I have isolated the problem to happen only when Google Play Services is not working or is outdated. Only SOMETIMES Android shows a notification "The app XXXXXX will not work until Play Services is updated"
I found this code to check Play Services:
So, I have some questions:
1. Where/how can I trap this error (Exception java.lang.SecurityException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gms (has extras) } ) before it crashes the app?
2. Which firebase services require this check? Notifications, remote config, Analitics?
3. It can be checked on starter and stop services to be created?
Thanks
B4X:
Exception java.lang.SecurityException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gms (has extras) } without permission com.google.android.c2dm.permission.RECEIVE
android.app.ContextImpl.startServiceCommon (ContextImpl.java:1409)
android.app.ContextImpl.startService (ContextImpl.java:1386)
android.content.ContextWrapper.startService (ContextWrapper.java:613)
com.google.firebase.iid.zzan.zze ()
com.google.firebase.iid.zzan.zzd ()
com.google.firebase.iid.zzan.zzc ()
com.google.firebase.iid.zzo.zza ()
com.google.firebase.iid.zzp.run ()
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1133)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:607)
java.lang.Thread.run (Thread.java:761)
The problem is NOT about security or permissions, the app is working in most cases. I have isolated the problem to happen only when Google Play Services is not working or is outdated. Only SOMETIMES Android shows a notification "The app XXXXXX will not work until Play Services is updated"
I found this code to check Play Services:
B4X:
Sub CheckForGooglePlayServices As Boolean
Dim GoogleApiAvailablity As JavaObject
GoogleApiAvailablity = GoogleApiAvailablity.InitializeStatic("com.google.android.gms.common.GoogleApiAvailability").RunMethod("getInstance", Null)
Dim context As JavaObject
context.InitializeContext
If GoogleApiAvailablity.RunMethod("isGooglePlayServicesAvailable", Array(context)) <> 0 Then
GoogleApiAvailablity.RunMethod("makeGooglePlayServicesAvailable", Array(context))
Return False
End If
Return True
End Sub
So, I have some questions:
1. Where/how can I trap this error (Exception java.lang.SecurityException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gms (has extras) } ) before it crashes the app?
2. Which firebase services require this check? Notifications, remote config, Analitics?
3. It can be checked on starter and stop services to be created?
Thanks
Last edited: