Android Question Error Sending Request

Endien

Member
Licensed User
Longtime User
Hi all,

I had manage to run GCM tutorial from Erel's https://www.b4x.com/android/forum/threads/android-push-notification-gcm-framework-and-tutorial.19226/.
From the code, i change the senderID, DeviceBoardPassword, and BoardUrl to my web host address.
The registration run fine and i confirmed that the registration record saved on my web host.

But when i tried the code on my app, on the registration process, it shows toastMessage "Error Sending Request" and on from the Log(Job.ErrorMessage) its said "Forbidden".

What could be the problem?
Is it because my permission set on manifest?

B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
   
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:theme, "@android:style/Theme.Holo.Light")
AddPermission(android.permission.RECEIVE_SMS)
AddReceiverText(s1,
<intent-filter>
    <action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>)

'C2DM Permissions
AddManifestText(<permission android:name="$PACKAGE$.permission.C2D_MESSAGE" android:protectionLevel="signature" />)
AddPermission($PACKAGE$.permission.C2D_MESSAGE)
AddPermission(com.google.android.c2dm.permission.RECEIVE)
' Push Service Receiver Attribute
SetReceiverAttribute(PushService, android:permission, "com.google.android.c2dm.permission.SEND")
' Service Receiver Text
AddReceiverText(PushService,
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="$PACKAGE$" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="$PACKAGE$" />
</intent-filter>)
 

Endien

Member
Licensed User
Longtime User
Turn out that this is the cause :

On Erel's example :
B4X:
Sub Register(Name As String)
   DeviceName = Name
   CallSubDelayed2(PushService, "RegisterDevice", False)
End Sub


On my code, it should be :

B4X:
Sub Register(Name As String)
   Main.DeviceName = Name
   CallSubDelayed2(PushService, "RegisterDevice", False)
End Sub

Because on my app i use many Activity.
 
Upvote 0
Top