Android Question FirebaseMessaging

heo jin young

Member
Licensed User
B4X:
#Region Service Attributes
    #StartAtBoot: False
    #ExcludeFromLibrary: True
#End Region

Sub Process_Globals

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
End Sub

Sub Service_Create
    'need to disable it as reading from large JdbcResultSet will cause network requests to be sent on the main thread.
    'DisableStrictMode
    CallSubDelayed(FirebaseMessaging, "SubscribeToTopics")
End Sub

Sub Service_Start (StartingIntent As Intent)

End Sub

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

Sub Process_Globals
    Private fm As FirebaseMessaging
End Sub

Sub Service_Create
    fm.Initialize("fm")
End Sub

Public Sub SubscribeToTopics
    fm.SubscribeToTopic("general") 'you can subscribe to more topics
End Sub

Sub Service_Start (StartingIntent As Intent)
    If StartingIntent.IsInitialized Then fm.HandleIntent(StartingIntent)
    Sleep(0)
    Service.StopAutomaticForeground 'remove if not using B4A v8+.
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

B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="26"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>
  )
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.DarkTheme)
SetActivityAttribute(main, android:windowSoftInputMode, adjustResize|stateHidden)

CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)
'End of default text.

compile -----> "There was a problem parsing the package"

It is very difficult to send text to cell phones!
 

Attachments

  • upload_2018-6-15_2-26-19.png
    upload_2018-6-15_2-26-19.png
    130.5 KB · Views: 186
  • upload_2018-6-15_2-28-45.png
    upload_2018-6-15_2-28-45.png
    52 KB · Views: 194
  • upload_2018-6-15_2-29-50.png
    upload_2018-6-15_2-29-50.png
    58.9 KB · Views: 212
Last edited:

KMatle

Expert
Licensed User
Longtime User
compile -----> "There was a problem parsing the package"

Change the package name to LOWERCASE -> hicar.project even better if it's more unique like country, your name or company and app name

Example: ch.heojin.hicar

If you have several apps, the package name will be different only in the last part and will be unique. You are not allone in the world. Others may have projects with the same name. "hicar" is for sure NOT unique.

It is very difficult to send text to cell phones!

No, It's very easy when you know how. A lot of developers start with complex apps too early.

Additionally:

If the error says "package" then it means that there's something wrong with the package, not firebase :)
 
Upvote 0

heo jin young

Member
Licensed User
May I ask you more?

B4X:
Dim r As Reflector
    r.Target = r.RunStaticMethod("android.telephony.SmsManager", "getDefault", Null, Null)
    Dim parts As Object
    parts = r.RunMethod2("divideMessage", "Hellow!", "java.lang.String")
    r.RunMethod4("sendMultipartTextMessage", _
      Array As Object("01012341234", Null, parts, Null, Null), _
      Array As String("java.lang.String", "java.lang.String", _
         "java.util.ArrayList", "java.util.ArrayList", "java.util.ArrayList"))

B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="26"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>
  )
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.DarkTheme)
SetActivityAttribute(main, android:windowSoftInputMode, adjustResize|stateHidden)

AddPermission(android.permission.SEND_SMS)
AddPermission(android.permission.WRITE_SMS)
AddPermission(android.permission.READ_SMS)

There is no error but no execution result...
Thanks in response
 
Upvote 0
Top