Edit Push Notification

Hey there,
I am using this https://fuseopen.com/docs/fuse/pushnotifications/push.html
And it works fine. But I need to edit the notification build. Could you help me where I can find that?
The reason: I send the notification from the server, but on the device I have two different languages. I need to figure that out in the APP an show only the notification in the special language. For that I need to edit the notification. But I can not find :hear_no_evil:
Thanks for help! :slight_smile:

You can just pass a value in the payload of your push notification, then in the app, just check the value:

push.on("receivedMessage", function(payload) {
    console.log("Recieved Push Notification: " + payload);
    payloadData = JSON.parse(payload);
    switch (payloadData.language) {
        case 'en': //do something in english
            break;
        case 'fr': //do something in french
            break;
    }
});

Thanks for reply!
But with this code I only can edit the text, wich pushes, when the app i in foreground. I mean the Notification, wich appears, when the app is in background.
For Android i mean this: https://developer.android.com/training/notify-user/build-notification

Oh, I think you’re talking about a notification that occurs when the app is closed or minimized in the background, that is caused by the payload structure, for android, it looks like this (for it to be silent, you can remove the “alert” and sound parts):

        notification: {
            alert: {
                title: "Greeting 1",
                body: "Hello there!",
                sound: "default",
            }
        }

Yeah this works great. But the only thing is, how to edit this notification :speak_no_evil: if I can edit this, I know how to set the message for two languages.
You know what I mean? :slight_smile:

Well it’s usually set/created by your server side logic, so you would have to handle the multiple languages there. The example in fuses docs were to be able to test push notifications without setting up a server side implementation it’s typically not used as the sending platform.

I am really sorry, but I don’t understand :speak_no_evil: how can I handle on server side if a user needs the string for language one or language two?
:v:t3:

Here you go:

e.g.

  1. User opens app
  2. User enables push notifications
  3. The App asks the User to select a language
  4. The App saves the Users language to Database via API back end
  5. The platform(server side) sends a push notification to all new users saying either “hello” or “bonjour” based on their selection in the Database

If you really want to hard code your messages in the app module, you can find the source for that module here: https://github.com/fuse-open/fuselibs/tree/master/Source/Fuse.PushNotifications

Thank you very much! I going to try this all out. And let you know what I used :slight_smile:

1 Like

Thanks for your Replys! :slight_smile:
I have solved this for me by registering the user for the special topic:
example the english people will be registered for topic_name_en and the german people will be registered for another topic topic_name_de.
And on server side I send to both the _en and _de version. So the user will only get his/her language :smiley:

You’re welcome man, I knew you could do it, all the best with getting your app over the finish line! :beers:

thank you :slight_smile: :beers::grin: