Unable to manage GCM notification

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Unable to manage GCM notification

Post by LCNeil » Fri Jul 17, 2015 8:36 am

Hi Sphere,

That site is not run by us so cant say why your IP is banned. It could be an block IP ban where multiple IPs are banned at the same time and yours just happens to be in that pool.

To help out, I've copied and pasted the contents of the forum post below-

----------
John Craig just posted a note to the LiveCode Dev list about a neat stack he made that simplifies the process of getting push notifications set up for your iOS app. Here's the post:

John Craig wrote:
I think I sighed when I saw the 'How do I use Push Notifications with iOS?' document - great feature, but more hoops to jump through!
I've created a small stack to make things quicker. It worked OK for me on Snow Leopard, but you might need to tweak it for Lion, etc. -
I can't be sure as I've not made the jump yet.


There's a video here;
http://youtu.be/v7nR_aEAdKA

And if you think it might be useful, you can grab the stack here;
http://splash21.com/downloads/APNsAssistant.zip

UPDATE:
John Craig wrote:
A couple of snippets from the APNs docs;

---
If a provider attempts to deliver a push notification to an application, but the application no longer exists on the device, the device reports that fact to Apple Push Notification Service. This situation often happens when the user has uninstalled the application. If a device reports failed-delivery attempts for an application, APNs needs some way to inform the provider so that it can refrain from sending notifications to that device. Doing this reduces unnecessary message overhead and improves overall system performance.

---
Note: APNs monitors providers for their diligence in checking the feedback service and refraining from sending push notifications to nonexistent applications on devices.



I couldn't get any data back from the sandbox feedback service, even after uninstalling my test app. The notifications were actually queued and delivered to the app when I reinstalled it on the device!! I found a couple of posts online saying that the sandbox feedback service only works if you have ANOTHER push notify enabled app using the sandbox APNs service at the same time, so I stuck another app on the device and it worked - notifications of devices with failed delivery attempts are now reported, so they can be removed from your database, etc.

I've updated the stack with a feedback tab. After I sent a couple of notifications that failed to deliver, the device was listed in the feedback - I've left the data in the stack as an example.

http://splash21.com/downloads/APNsAssistant.zip

-------

Kind Regards,

Neil Roger
--
LiveCode Support Team ~ http://www.livecode.com
-

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: Unable to manage GCM notification

Post by dave.kilroy » Fri Jul 17, 2015 9:46 am

Hi sphere - yeah i've had that experience with livecodejournal too :) - I think Richard has to use some super-paranoid security as he was (still is?) being spam-bombed (think I just made up a new term "spam-bombed) - what I did was to email Richard Gaskin telling him "I am a free man, I am not a spam-bot" - Richard replied quickly and I've never had a problem since..

Dave
"...this is not the code you are looking for..."

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am

Re: Unable to manage GCM notification

Post by sphere » Fri Jul 17, 2015 10:43 am

@ Neil: Great ! thanks very much for your effort!
@ Dave: Hahaha Thanks, great term :shock:

and i've a lot to learn to get it to work on Android, reading the stuff on GCM and the lessons here on Livecode and the forum.

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am

Re: Unable to manage GCM notification

Post by sphere » Fri Jul 17, 2015 12:15 pm

One thing i don't understand is (after seeing your Movie Neil on this thread http://forums.livecode.com/viewtopic.ph ... on#p113366)
Does this have to be done on every device that is going to run your app?

My understanding(and correct me if i'm wrong) is that you have to do this once and then every phone that will run your app will get the push notification.
I understand that the app must send a key or so to get registered at the gcm server, now it looks like you have to check every phone separately?

Could you please explain a bit (i have read the lesson on Push notiification) but it is not clear to me.
Sorry for that.

Isn't it a bit like with the Dropbox api? you have a key and an ID, and together they create a author key. And all 3 have to be in the app?

Thanks for some more explanation on this.

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am

Re: Unable to manage GCM notification

Post by sphere » Fri Jul 17, 2015 9:57 pm

Hi,

i don't know why it works with you Neil, but when i copy the script from the Push notification lesson, then nothing happens.

When i call the handler with

Code: Select all

on openStack
pushNotificationRegistered
end openStack

on pushNotificationRegistered tMessage
answer "Registered:" && quote & tMessage & quote with "Okay"
end pushNotificationRegistered
then i get : Registered:""
so no key is returned, perhaps because tMessage is empty?
I tried both the Sender ID and Project ID

-----one other thing it seems to me kind of unlogical to recieve all the device tokens, meaning you have to add all these devicetokens to the send push application? How does for example Whatsapp do somthing like this with millions of users? Just store the id in a server i think right? and not in the send push app?------I have read a lot on google dev pages but still seems unlogical or i must just not understand it----

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Unable to manage GCM notification

Post by Simon » Sat Jul 18, 2015 12:49 am

Hi sphere,
..then every phone that will run your app will get the push notification.
I don't believe that is how push is supposed to work but rather communication with unique devices. Yes, that means you can do a mass push but, if I recall correctly one of the things they always talked about was reducing bandwidth by targeting devices.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am

Re: Unable to manage GCM notification

Post by sphere » Sat Jul 18, 2015 9:55 am

Hi Simon,

ah ok thanks for your comment.
So in fact i should create an opt-in or opt-out so users can decide for them selves if they want to be notified or not, ok thats fair.

So back to testing.

THanks!

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am

Re: Unable to manage GCM notification

Post by sphere » Sat Jul 18, 2015 8:18 pm

Ok i'm a step further.

1 You need to have Google Play Services installed in the Android SDK (under Extra's)
2 You need to have 2 Step verification in your google account.
3 Don't put in the project nr:123456 but the Project ID:pushtest-1234 in the Push Sender ID standalone settings in Android.

As a result of the 2 Step verification, the Pushnotification stack from Neil is not accepting any 2 Step password created on google (see the movie Neil made) allthough it does work in his movie, i tried several instants. Also the option Less secure Apps must be enabled in google as far as i noticed.

I did not get any token back from the Android Emulator (tried 3 different ones), I did not get any token back on my Samsung Sii with Cyanogenmod 12.1 (lollipop) with Google Play services running ok. I finnally did get a token back from my wifes Samsung phone with original Samsung firmware.

So now for the test the 2 Step password in Livecode stack is not working.
Any suggestions?
Thanks!

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am

Re: Unable to manage GCM notification

Post by sphere » Tue Jul 21, 2015 6:54 am

In passing by the 2 step issue a bit easier, i created a database on my website.
I will post a few links which helped me understand it a bit more and also with some php examples.

I adjusted a php file i used for an other project.
Now my test stack is sending the response token it gets from the gcm server, via this php file and inserts it into the database.

Then i use a gcm php file to send a push. It reads the token and sends it with the message and the sender ID to the gcm server, so the gcm server can send out a push.

and now we have a new headbreaker :twisted: , i get back a kind of idmismatch error .

Now that is a bit strange i think, because the token you receive on the android was created by using the sender ID in the livecode-android-app(test stack)

Maybe i forgot something, i don't know yet. Checking some site like stackoverflow and such but no good solution yet

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am

Re: Unable to manage GCM notification

Post by sphere » Tue Jul 21, 2015 5:51 pm

ok the mismatchsenderid is solved.
It seems if you use either the Project ID or the Project number, in both cases the phone will get the token. So that's a bit confusing.
You have to use the Project Number and set it in the Standalone settings.
senderID.JPG
these links are very helpfull:

http://www.androidhive.info/2012/10/and ... and-mysql/
http://stackoverflow.com/questions/2585 ... -using-gcm

now i get the tokens received in my database and finally i get a Succes returned from the gcm server, but...i still do not see any push notification on my phone
so hopefully a final step to solve

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am

Re: Unable to manage GCM notification

Post by sphere » Sun Sep 06, 2015 11:42 am

I'm still havinf troubles with this issue.
I'm now trying to use a Zend script to see if this will help.
Untill now i managed to get the pushnotification token, i could send a push message with positive result from google's server, but it never was received on the phone.

Checking the dictionary i see this:

Code: Select all

on pushNotificationRegistered tSignature
   answer "Registered for Push Notification:" && quote & tSignature & quote with "Okay"
end pushNotificationRegistered
and

Code: Select all

on pushNotificationRegistered
   get mobileGetDeviceToken()
end pushNotificationRegistered
can anybody explain the difference or are they the same, then why? ***edit*** the token is the same(of course...)


Then where should this below mentioned piece of script be putted exactly, in the stack script? before or after the pushnotificationregistered ?
Should the be called like any other handler or is that not neccessary?

Code: Select all

on pushNotificationReceived tMessage
   answer "Push Notification:" && quote & tMessage & quote with "Okay"
end pushNotificationReceived
thanks a lot for your patience and help.

Sphere

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Unable to manage GCM notification

Post by FourthWorld » Sun Sep 06, 2015 6:46 pm

sphere wrote:
dave.kilroy wrote:sorry to hear that Gianluca and I'm afraid I don't have the relevant experience to help you (maybe some kind expert will chime in soon)

There is a guy called John Craig (splash21.com - who also does MobGUI) who was one of the first to get push notifications going with LiveCode - this thread is a couple of years old and may be too old now but it does include a sample stack http://livecodejournal.com/forum/viewto ... ?f=27&t=55 and video.

Also and finally (the last thing I can think of) have you tried multiple searches here in the Forum?

Dave

EDIT: one other thing, have you tried with different Android devices?

wow! :twisted: if i go to that URL....i'm instantly banned!!!! My IP is registered. God knows why? What the H*ll did i do??? It's my first visit to that site ever! :evil: :evil: :evil:
Whenever a web site is behaving badly it can be helpful to write the site owner. LiveCodeJournal.com has a Contact page at the top of each non-forum page on the site.

The problem you experienced appears to have been related to counter-measures we had to put into place to stop a massive flood of spambots who were attacking the site with alarming frequency. To minimize the impact of these bots we had to move beyond blocking individual IP addresses to blocking IP ranges. This was put into place for the forums only; all of the other content at LiveCodeJournal.com is read-only, so there's no risk to our visitors by allowing access to all addresses for content outside the forums. Overall using this common IP range restriction method has been effective, dropping the rate of malicious activity to near-zero, though it has resulted in about five false-positives over the last two years, apparently yours among them.

I've just refined the list of blocked IP ranges, so please feel free to try accessing the forum at LiveCode Journal again. If you find your IP address is still blocked please send me an email to ambassador AT fourthworld.com with your IP address included and I'll see if I can refine the list further to allow access for you.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am

Re: Unable to manage GCM notification

Post by sphere » Sun Sep 06, 2015 7:25 pm

Ok i found something that finnaly does work.
http://forums.livecode.com/viewtopic.ph ... 41#p131241

hopefully i can use that. :D :D :D
Last edited by sphere on Sun Sep 06, 2015 9:10 pm, edited 1 time in total.

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am

Re: Unable to manage GCM notification

Post by sphere » Sun Sep 06, 2015 9:03 pm

Thanks Richard, for your help!
I can read it now :D :D

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: Unable to manage GCM notification

Post by dave.kilroy » Sun Sep 06, 2015 9:05 pm

sphere could you check that link again?
sphere wrote:Ok i found something that finnaly does work.
http://forums.livecode.com/posting.php? ... 53&t=12864

hopefully i can use that. :D :D :D
"...this is not the code you are looking for..."

Post Reply