Hi, Guys
I have a problem with string comparison, the line
IF fcmToken = webFcmToken then always fails (see code below).
I have viewed tokens with in debug an they appear identical. Also tried .trim and even .toupper but still failed the comparison.
Also tried fcmToken.compare(webFcmToken) and got the result 67!
I think it is something to do with encoding - fcmToken is taken from my code after it calling firebasemessaging.SubscribeToTopic("general") and the other (webFcmToken) is from web based database.
Example code below - I have marked the problem statement with <<<< ALWAYS FAILS
Any ideas?
Kind regads
Dave
I have a problem with string comparison, the line
IF fcmToken = webFcmToken then always fails (see code below).
I have viewed tokens with in debug an they appear identical. Also tried .trim and even .toupper but still failed the comparison.
Also tried fcmToken.compare(webFcmToken) and got the result 67!
I think it is something to do with encoding - fcmToken is taken from my code after it calling firebasemessaging.SubscribeToTopic("general") and the other (webFcmToken) is from web based database.
Example code below - I have marked the problem statement with <<<< ALWAYS FAILS
B4X:
' Query update FCM token - Returns true if FCM tokens are the same or the FCM token updated successfully.
private Sub QueryUpdateFcm(customerId As Int, fcmToken As String)As ResumableSub
Dim fcmUpdatedOk As Boolean = False
Dim jobGet As HttpJob: jobGet.Initialize("UseWebApi", Me)
jobGet.Download(modEposWeb.URL_CUSTOMER_API & "/" & customerId & "?" & modEposWeb.API_QUERY & "=" & modEposWeb.API_GET_FCMTOKEN)
wait for (jobGet) jobDone(jobGet As HttpJob)
If jobGet.Success And jobGet.Response.StatusCode = 200 Then
Dim webFcmToken As String = jobGet.GetString
If fcmToken = webFcmToken Then ' <<<< ALWAYS FAILS
fcmUpdatedOk = True
Else
Dim jobPut As HttpJob: jobPut.Initialize("UseWebApi", Me)
jobPut.PutString(modEposWeb.URL_CUSTOMER_API & "/" & customerId & "?" & modEposWeb.API_SETTING & "=" & _
modEposWeb.API_GET_FCMTOKEN & "&" & modEposWeb.API_SETTING_1 & "=" & fcmToken, "")
Wait For (jobPut) jobDone (jobPut As HttpJob)
If jobPut.Success And jobPut.Response.StatusCode = 200 Then
fcmUpdatedOk = True
End If
jobPut.Release
End If
End If
jobGet.Release
Return fcmUpdatedOk
End Sub
Any ideas?
Kind regads
Dave