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.