Display pop up notification

34 views
Skip to first unread message

Compte Gmail

unread,
May 12, 2021, 8:32:33 PM5/12/21
to CodenameOne Discussions
Hey guys I was trying this tutorial you made about displaying pop up notification, when I run the program nothing happens. It just doesn't display the notification, I kinda didn't know what to exactly put int the parameters can anybody help me by any chance? I need to resolve this in few days.


MyApplication.java implements PushCallback
--------------------------------------------------------------
    public void start() {
        if(current != null){
            current.show();
            return;
        }
        Hashtable meta = new Hashtable();
meta.put(com.codename1.push. Push. GOOGLE_PUSH_KEY, "1234");
Display.getInstance().registerPush(meta, true);

        Form hi = new Form("Hi World", BoxLayout.y());
        hi.add(new Label("Hi World"));
        Button send= new Button("send");
        send.addActionListener(new ActionListener() {
        
        public void actionPerformed(ActionEvent evt){
            Push.sendPushMessage("Message", null, false, SOUTH, NATIVE_ITALIC_THIN, NATIVE_ITALIC_BOLD);
        }
        
        });
        hi.show();
    }

Best regards.

Shai Almog

unread,
May 12, 2021, 11:13:24 PM5/12/21
to CodenameOne Discussions
Hi,
That's a video from 2014 and a lot has changed since then. Please follow the push instructions in the developer guide which are more up to date: https://www.codenameone.com/developer-guide.html

The push process was changed by Google/Apple several times over the past 7 years.

Compte Gmail

unread,
May 13, 2021, 3:26:32 PM5/13/21
to CodenameOne Discussions
Sir can you send me the code I'm struggling to find the it in the section or at least its link. Also should I edit any extra things in the settings? I saw in some videos that I need to add something in the build hints of the project's settings.

Hannah R

unread,
May 13, 2021, 4:44:52 PM5/13/21
to CodenameOne Discussions

Check this part:
https://www.codenameone.com/developer-guide.html#_implementing_push_support
and this 
https://www.codenameone.com/files/push-cheatsheet.pdf
You can test push notifications in the cn1 simulator. (Simulate - Push Simulation). Once you make it work in simulator, it'll be easier to test it on device. 
Reply all
Reply to author
Forward
0 new messages