Android Question Threading Sub not called

Dianzoa

Active Member
Licensed User
Hello, I am using this example code, to remove topic, code not entering Sub Thread1, and therefore not removing the subscribed topic

B4X:
#Region  Service Attributes
    #StartAtBoot: false
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Private fm As FirebaseMessaging
    Dim Thread1 As Thread
End Sub

Sub Service_Create

    fm.Initialize("fm")
    Thread1.Initialise("Thread1")

End Sub

Public Sub subscribeToTopic

    fm.SubscribeToTopic("DebugTopic")
    Log ($"Token : ${fm.Token}"$)

End Sub

Public Sub removeToken()

    Dim args(0) As Object
    Thread1.Name = "B4A Thread 1"
    Thread1.Start(Null, "ThreadSub1", args)

End Sub

Sub ThreadSub1

    Dim jo As JavaObject

    Try
        jo = jo.InitializeStatic("com.google.firebase.iid.FirebaseInstanceId").RunMethod("getInstance", Null)
        jo.RunMethod("deleteInstanceId", Null)
    Catch
        Log(LastException)
    End Try

End Sub

Sub Thread1_Ended(fail As Boolean, error As String) 'An error or Exception has occurred in the Thread

    If Not(fail) Then
        Log ($"Thread1 Ended with error : ${error}"$)
    Else
        Log ("Thread1 Ended without error")
    End If

End Sub

Sub fm_MessageArrived (Message As RemoteMessage)

   Log("Message arrived")
   Log($"Message data: ${Message.GetData}"$)
   Dim n As Notification
   n.Initialize
   n.Icon = "icon"
   n.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), Main)
   n.Notify(1)

End Sub

Sub Service_Destroy
End Sub
 
Last edited:

Dianzoa

Active Member
Licensed User
Since I thought that I need the code above to unsubscribe from FCM topics, I found that I only need to unsubscribe from 1 topic for any UserID, so just calling. I will check if it actually remove the subscription.
B4X:
fm.UnsubscribeFromTopic(ID)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…