Android Question FirebaseMessaging

Discussion in 'Android Questions' started by heo jin young, Jun 14, 2018.

  1. heo jin young

    heo jin young Member Licensed User

    Code:
    #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
    Code:
    #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
    Code:
    '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!
     

    Attached Files:

    Last edited: Jun 14, 2018
  2. KMatle

    KMatle Expert Licensed User

    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.

    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 :)
     
    BillMeyer and heo jin young like this.
  3. heo jin young

    heo jin young Member Licensed User

    That's right.
    Thank you very much!
     
  4. heo jin young

    heo jin young Member Licensed User

    May I ask you more?

    Code:
    Dim r As Reflector
        r.Target = r.RunStaticMethod(
    "android.telephony.SmsManager""getDefault"NullNull)
        
    Dim parts As Object
        parts = r.RunMethod2(
    "divideMessage""Hellow!""java.lang.String")
        r.RunMethod4(
    "sendMultipartTextMessage", _
          
    Array As Object("01012341234"Null, parts, NullNull), _
          
    Array As String("java.lang.String""java.lang.String", _
             
    "java.util.ArrayList""java.util.ArrayList""java.util.ArrayList"))
    Code:
    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
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice