mohsen programmer
Member
Hello
I use the following code in Service_Create in my starter to send a notification with firebase:
There are also functions in this service (starter).
In these functions, methods from the code module are called:
I call the download method from the main activity:
The first time I ran the app and clicked on Button1, the download was completed and everything worked properly.
I exited the app (I also clear it from the recent list) and entered the app again. The second time it worked correctly and I exited again.
But for the third time when I entered the app and clicked on Button1, the following error appeared:
I also created a separate service to call the SubscribeToTopics method using callsub.
But it had no effect and this error occurred regularly after opening and closing the app two or three times.
Why does this happen? how to solve
Another question!
If I Remove the FirebaseMessaging service, but the Firebase permissions remain in the manifest, can I still send notifications to users from the Firebase console or analyze their activity? Or will there be a disturbance?
I use the following code in Service_Create in my starter to send a notification with firebase:
B4X:
Sub Service_Create
Try
CallSubDelayed(FirebaseMessaging, "SubscribeToTopics")
Catch
End Try
End Sub
In these functions, methods from the code module are called:
B4X:
Sub Download(token As String)
Dim MyDownloadLink As String = MyModuleCode.GetLink
Dim encryptedToken As String = MyModuleCode.encrypt(token)
Dim http As HttpJob
http.Initialize("http",Me)
http.Download(MyDownloadLink&"?token="&encryptedToken)
End Sub
B4X:
Private Sub Button1_Click
Starter.Download(MyToken)
End Sub
I exited the app (I also clear it from the recent list) and entered the app again. The second time it worked correctly and I exited again.
But for the third time when I entered the app and clicked on Button1, the following error appeared:
B4X:
*** Service (starter) Create ***
stopping spontaneous created service
** Service (starter) Destroy (ignored)**
sending message to waiting queue (CallSubDelayed - SubscribeToTopics)
** Activity (main) Create (first time) **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create (first time) **
** Activity (main) Resume **
starter_Download (java line: 153)
java.lang.NullPointerException: Attempt to read from field 'b4a.example.MyModuleCode b4a.example.starter._MyModuleCode' on a null object reference in method 'java.lang.String b4a.example.starter._Download(java.lang.String, java.lang.String, java.lang.String, long, java.lang.Object)'
at b4a.example.starter._Download(starter.java:153)
at b4a.example.main$ResumableSub_t_ResponseBody.resume(main.java:3797)
at b4a.example.main._t_responsebody(main.java:3072)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1114)
at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:1077)
at b4a.example.MyModuleCode3$ResumableSub_t_onNext.resume(MyModuleCode3.java:399)
at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1748)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:230)
at android.os.Looper.loop(Looper.java:319)
at android.app.ActivityThread.main(ActivityThread.java:8893)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
java.lang.NullPointerException: Attempt to read from field 'b4a.example.MyModuleCode b4a.example.starter._MyModuleCode' on a null object reference in method 'java.lang.String b4a.example.starter._Download(java.lang.String, java.lang.String, java.lang.String, long, java.lang.Object)'
But it had no effect and this error occurred regularly after opening and closing the app two or three times.
Why does this happen? how to solve
Another question!
If I Remove the FirebaseMessaging service, but the Firebase permissions remain in the manifest, can I still send notifications to users from the Firebase console or analyze their activity? Or will there be a disturbance?