Android Question Problem with Android push notification (GCM)

Yayou49

Active Member
Licensed User
Hi,

Based on Erel's tuto, I'm trying to run the example code (https://www.b4x.com/android/forum/t...otification-gcm-framework-and-tutorial.19226/)

I've registered GCM in google API for my project
I've updated SenderId with mine in B4A code.

With the original code, I get this error:
Service Intent must be explicit: Intent { act=com.google.android.c2dm.intent.REGISTER (has extras) }

I've updated sub "RegisterDevice" with Erel's code proposal:

B4X:
    Dim i As Intent
    If Unregister Then
        i.Initialize("com.google.android.c2dm.intent.UNREGISTER", "")
    Else
        i.Initialize("com.google.android.c2dm.intent.REGISTER", "")
        i.PutExtra("sender", Main.SenderId)
    End If
    Dim jo As JavaObject = i
    jo.RunMethod("setPackage", Array("com.google.android.gms"))
    Dim r As Reflector
    Dim i2 As Intent
    i2 = r.CreateObject("android.content.Intent")
    Dim pi As Object
    pi = r.RunStaticMethod("android.app.PendingIntent", "getBroadcast", _
     Array As Object(r.GetContext, 0, i2, 0), _
     Array As String("android.content.Context", "java.lang.int", "android.content.Intent", "java.lang.int"))
    i.PutExtra("app", pi)
    StartService(i)

and the error became "Not found" on jobdone result.

I ran both code on emulator and real device.

I really don't know what to do ...
Any idea ?
 

BillMeyer

Well-Known Member
Licensed User
Longtime User
Upvote 0

Yayou49

Active Member
Licensed User
Hi BillMeyer,

I did as you said.

While running my app, I get an error about manifest and don't understand why ....
Here is my manifest:


At the end of compilation, I've got this error:


I've just added the 3 last lines.
 
Last edited:
Upvote 0

Yayou49

Active Member
Licensed User
after some tests, the involved line generated this error is
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)

If I remove this line from the manifest, no error on compilation. Just an error on service start.
 
Upvote 0

Yayou49

Active Member
Licensed User
In fact, it was due to 2 different problems:
- library were not up to date
- effectively, package name was in upper case.
Both corrected and it works.
Thx.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…