Push notifications on Android clean register?

35 views
Skip to first unread message

phsp...@gmail.com

unread,
Feb 27, 2015, 3:57:13 AM2/27/15
to codenameone...@googlegroups.com
Hi there,

I just brought push notifications "to work" (not entirely yet) and I need some help. So I need to send push from device to device, both on Android. At the moment I send my push to all device key by setting the null parameter but when I send 1 push i receive the notification 7 time on my devices. I tested to register many time without deregister to test what I found in developer guide "its OK to call register every time the app loads".

I tried to unregister, uninstall app, reinstall, regenerate google API key but I still receive my push 7 time on my devices.  I suppose it comes from many registrations and I want to know if it's possible to clean without creating new google project, with other key, etc etc. 

Some code:

- registration:
Hashtable meta = new Hashtable();
        meta.put(com.codename1.push.Push.GOOGLE_PUSH_KEY, "projectid");
        Display.getInstance().registerPush(meta, true);

- send:
boolean sent = Push.sendPushMessage("Bonjour je suis un push!", null, true, "apikey", "", "", "", "", "", "");

- deregister:
Display.getInstance().deregisterPush();

- how I overwritted push method from pushcallback:
Display.getInstance().callSerially(new DisplayDialogs(value));

where value is the push string value and DisplayDialogs is a runnable which displays the value and by the way creates test button in a test container:
 public void run() {
           
Button b = new Button("PUSH BTN");
           
Container c = sm.findContBtn(sm.f);
           
if (c != null) {
                c
.addComponent(b);
           
} else {
               
Dialog.show("Null", "Container null", "OK", null);
           
}
           
Dialog.show("Push Received", value, "OK", null);
       
}

Result: 7 buttons and 7 Dialog boxes.

memot...@gmail.com

unread,
Feb 27, 2015, 4:42:46 AM2/27/15
to codenameone...@googlegroups.com, phsp...@gmail.com
Just correcting me, I just get the notification 7 time on one device, an other device registered once get the notification once.

Shai Almog

unread,
Feb 27, 2015, 10:27:26 AM2/27/15
to codenameone...@googlegroups.com, phsp...@gmail.com, memot...@gmail.com
There is a bug on Android related to this. I'm not sure if its in the issue tracker but we do need to fix it.
It occurs when you uninstall/reinstall a registered app over and over.
Reply all
Reply to author
Forward
0 new messages