GCM - Problem handling Message Received

flyingbag

Member
Licensed User
Longtime User
Hello,
In my MessageArrived event (in PushService) example of GCM Tutorial
I am trying to start a new service svc_test
I get the "new message arrived" but the new service does NOT start ...
not sure what is going wrong...

Sub MessageArrived (Intent As Intent)
Dim From, CollapseKey, Data As String
If Intent.HasExtra("from") Then From = Intent.GetExtra("from")
If Intent.HasExtra("data") Then Data = Intent.GetExtra("data")
If Intent.HasExtra("collapse_key") Then CollapseKey = Intent.GetExtra("collapse_key")

'Here you should handle the new message:
Log("New message arrived: " & Data)
ToastMessageShow("New message: " & Data, True)
StartService("svc_test")
end Sub


Please bear with noob qns - still less than a month b4a-"old" :)
THanks
flyingbag
 

flyingbag

Member
Licensed User
Longtime User
Hi Erel,
I want to start a new service which does some work (connect to server, send some data, close the socket etc) - so i wanted to keep that code separate
IN the logs - it logs the message received and does nothing after that...

I managed to get it working. I think this is the problem:
To start a service after receiving the message - the existing app (with the GCM intent code) needs to be running

However - if i use "CallSubDelayed(mysvcname,mymethod) then the service gets started even if the base application is not running...

I assume this is the problem - but since its fixed i am ok for now ..
Cheers
FlyingBag
 
Upvote 0
Top