Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

iOS is not showing any alert style nor sound option for push notifications #268

Closed
pliablepixels opened this issue Oct 27, 2015 · 6 comments

Comments

@pliablepixels
Copy link

Hi folks, I have integrated this plugin into an ionic app. The problem I am facing is that when I go to Notification center, I don't see any option to configure the display style or enable sound! But everything else works - I get notifications etc.

I am in IOS 9.1 (had the same problem with 9.0.1)

Here is how the app looks in notification settings: (Note no sound or style option)
twqe6

Here is how I am initializing the plugin - this is happening in a factory - the code is not directly inside app.js. I don't think that should matter. When I run the app the first time, it prompts me for enabling push notifications and I say yes.

Any clues on where to look?

@macdonst
Copy link
Member

@pliablepixels what do you pass to the init method?

@pliablepixels
Copy link
Author

@macdonst I'm sorry - looks like I forgot to add that code

var push = PushNotification.init(
                    { "android": 
                     {"senderID":zm.gcmSenderId,
                      "icon":"ic_stat_notification"
                     }
                    },

                     { "ios": 
                     {"alert": "true", 
                      "badge": "true", 
                      "sound": "true"}
                    }  

@pliablepixels
Copy link
Author

Well guess what? If I stuff in both android and iOS into the same init (like the example shows), these options are not displayed. But if I separate them out - i.e only do iOS for iOS and Android for Android depending on platform everything works!

function pushInit()
    {
        ZMDataModel.zmLog ("Setting up push registration");
        var push;
        var plat = $ionicPlatform.is('ios') ? 'ios':'android';


        if (plat == 'ios')
        {
            push = PushNotification.init(

                     { "ios": 
                     {"alert": "true", 
                      "badge": "true", 
                      "sound": "true"}
                    }  

                );

        }
        else
        {
            push = PushNotification.init(

                    { "android": 
                     {"senderID":zm.gcmSenderId,
                      "icon":"ic_stat_notification"
                     }
                    }

                );

        }

@macdonst
Copy link
Member

@pliablepixels you didn't format your JSON properly. This should work:

var push = PushNotification.init({
    "android":  {
        "senderID":zm.gcmSenderId,
        "icon":"ic_stat_notification"
    },
    "ios": {
        "alert": "true", 
        "badge": "true", 
        "sound": "true"
    }
});

@pliablepixels
Copy link
Author

@macdonst oh goodness - you are correct! Thank you!

@lock
Copy link

lock bot commented Jun 5, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants