iOS Question [Solved] Error on GetToken Method After New Version

George_G

Member
Licensed User
Hello,

my app does not working after the last update of B4I and B4iBuildServer. It is an app, in which user subscribes to a topic (Firebase push notification),
and after the subscription, I use a method named GetToken. (I found this method in another post)

B4X:
Private Sub GetToken As String
    Dim no As NativeObject
    Dim token As NativeObject = no.Initialize("FIRInstanceID").RunMethod("instanceID", Null).RunMethod("token", Null)
    If token.IsInitialized Then Return token.AsString Else Return ""
End Sub

But after the last update, when I compile my app and execute the GetToken method, I get this error (attached file).

The line of the error is this one: Dim token As NativeObject = no.Initialize("FIRInstanceID").RunMethod("instanceID", Null).RunMethod("token", Null)

Any advice?

Thank you in advance!
 

Attachments

  • Error.txt
    2.1 KB · Views: 65

George_G

Member
Licensed User
Just found this post


I will try it, and I will inform here.
 
Upvote 0

George_G

Member
Licensed User
Everything works fine now:

I replace my GetToken method with the following one:

Mr Erel used Dim token As Object, and I got Error.
I replace it with Dim token As NativeObject

B4X:
Private Sub GetToken As String
    Dim FIRMessaging As NativeObject
    FIRMessaging = FIRMessaging.Initialize("FIRMessaging").GetField("messaging")
    Dim token As Object = FIRMessaging.GetField("FCMToken")
    If token = Null Then Return "" Else Return token.As(String)
End Sub
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Are you getting it from this code:
B4X:
Private Sub GetToken As String
    Dim FIRMessaging As NativeObject
    FIRMessaging = FIRMessaging.Initialize("FIRMessaging").GetField("messaging")
    Dim token As Object = FIRMessaging.GetField("FCMToken")
    If token = Null Then Return "" Else Return token.As(String)
End Sub
?

Which line?
 
Upvote 0

George_G

Member
Licensed User
Are you getting it from this code:
B4X:
Private Sub GetToken As String
    Dim FIRMessaging As NativeObject
    FIRMessaging = FIRMessaging.Initialize("FIRMessaging").GetField("messaging")
    Dim token As Object = FIRMessaging.GetField("FCMToken")
    If token = Null Then Return "" Else Return token.As(String)
End Sub
?

Which line?
Dim token As Object = FIRMessaging.GetField("FCMToken")

but everything works fine with the following line

Dim token As NativeObject = FIRMessaging.GetField("FCMToken")
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Private Sub GetToken As String
    Dim FIRMessaging As NativeObject
    FIRMessaging = FIRMessaging.Initialize("FIRMessaging").GetField("messaging")
    Dim token As NativeObject = FIRMessaging.GetField("FCMToken")
    If token.IsInitialized = False Then Return "" Else Return token.AsString
End Sub
This is the correct code. I will update the post.
 
Upvote 0
Top