Everlive Pushnotification sound

4 posts, 0 answers
  1. Douw3rd
    Douw3rd avatar
    3 posts
    Member since:
    Aug 2013

    Posted 02 Sep 2013 Link to this post

    I was trying to change the sounds used by the everlive push notification template on receiving a pushnotification, but have been unsuccessful so far.

    I mainly tried messing around with the main.js code:

    var pushSettings = {
                    android: {
                        senderID: androidProjectNumber
                    },
                    iOS: {
                        badge: "true",
                        sound: "true",
                        alert: "true"
                    },
                    notificationCallbackAndroid : onAndroidPushReceived,
                    notificationCallbackIOS: onIosPushReceived
                }

    Any one who can push me in the right direction?
  2. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 03 Sep 2013 Link to this post

    Hello Douwe,

    The sound boolean property specifies whether the device will play a notification sound or not. To specify a specific sound file, you should use the IOS.aps.sound property, see Everlive documentation.

    Regards,
    Steve
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Share feedback and vote for features on our Feedback Portal.
  3. Douw3rd
    Douw3rd avatar
    3 posts
    Member since:
    Aug 2013

    Posted 07 Sep 2013 Link to this post

    Hey Steve,

    thanks for your answer! 

    Reading the Everlive documentation you linked gives me the impression that everlive only support sounds options for IOS, not Android. Is this correct?

    Kind Regards,

    Douwe

  4. Ivan Pelovski
    Admin
    Ivan Pelovski avatar
    16 posts

    Posted 13 Sep 2013 Link to this post

    Hello Douwe,

    Playing a sound in iOS when receiving a notification is supported by the OS itself. You may specify the name of the media file and the OS will play it. This is not the case for Android. It does not support such feature out of the box, and you should play a sound programmatically when you receive a push notification. You can check the sample of the PushPlugin of Cordova:
    // Android
    function onNotificationGCM(e) {
     
        switch( e.event ) {
            // ...
            case 'message':
                // if this flag is set, this notification happened while we were in the foreground.
                // you might want to play a sound to get the user's attention, throw up a dialog, etc.
                if (e.foreground)
                {
                    $("#app-status-ul").append('<li>--INLINE NOTIFICATION--' + '</li>');
     
                    // if the notification contains a soundname, play it.
                    var my_media = new Media("/android_asset/www/"+e.soundname);
                    my_media.play();
                }
                else
                {   // otherwise we were launched because the user touched a notification in the notification tray.
                    if (e.coldstart)
                        $("#app-status-ul").append('<li>--COLDSTART NOTIFICATION--' + '</li>');
                    else
                    $("#app-status-ul").append('<li>--BACKGROUND NOTIFICATION--' + '</li>');
                }
            // ...
        }
    }


    Regards,
    Ivan Pelovski
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Share feedback and vote for features on our Feedback Portal.
Back to Top