New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOS custom push sound when app is in background #175

Closed
tmakaro opened this Issue Sep 28, 2015 · 6 comments

Comments

Projects
None yet
2 participants
@tmakaro

tmakaro commented Sep 28, 2015

Is having a custom push sound when app is in the background still a problem with this new plugin? The old plugin was never able to do it. The only way I have been able to do it is with a pure objective c program.

@macdonst

This comment has been minimized.

Show comment
Hide comment
@macdonst

macdonst Sep 29, 2015

Member

@tmakaro Yes, you can play a sound on iOS. Check out issue #17 for more information.

Member

macdonst commented Sep 29, 2015

@tmakaro Yes, you can play a sound on iOS. Check out issue #17 for more information.

@tmakaro

This comment has been minimized.

Show comment
Hide comment
@tmakaro

tmakaro Sep 29, 2015

I can't get it to work. alarm.caf works when app is in the forground only. When the app is in the background, all I get is the standard beep.
Where is my alarm.caf file supposed to be located? Am I running the wrong version?

tmakaro commented Sep 29, 2015

I can't get it to work. alarm.caf works when app is in the forground only. When the app is in the background, all I get is the standard beep.
Where is my alarm.caf file supposed to be located? Am I running the wrong version?

@tmakaro

This comment has been minimized.

Show comment
Hide comment
@tmakaro

tmakaro Sep 30, 2015

It has something to do with what IOS thinks my root folder is and what cordova thinks my root folder is.

The following works when I store alarm.caf in the www folder: (works when app is in forground but not when app is in background)

{
    "aps": {
        "alert": "test alarm", 
        "sound": "alarm.caf"
    }
}

 push.on('notification', function (data) {
     if (data.sound) {
         var snd = new Media(data.sound);
         snd.play();
     }
 });

This change below makes it work when the app is in the background but not when it is in the forground:

{
    "aps": {
        "alert": "test alarm", 
        "sound": "www/alarm.caf"
    }
}

tmakaro commented Sep 30, 2015

It has something to do with what IOS thinks my root folder is and what cordova thinks my root folder is.

The following works when I store alarm.caf in the www folder: (works when app is in forground but not when app is in background)

{
    "aps": {
        "alert": "test alarm", 
        "sound": "alarm.caf"
    }
}

 push.on('notification', function (data) {
     if (data.sound) {
         var snd = new Media(data.sound);
         snd.play();
     }
 });

This change below makes it work when the app is in the background but not when it is in the forground:

{
    "aps": {
        "alert": "test alarm", 
        "sound": "www/alarm.caf"
    }
}
@macdonst

This comment has been minimized.

Show comment
Hide comment
@macdonst

macdonst Oct 1, 2015

Member

@tmakaro Yeah, iOS assumes that the sound file is in root folder of your app. Using:

{
    "aps": {
        "alert": "test alarm", 
        "sound": "www/alarm.caf"
    }
}

push.on('notification', function (data) {
     if (data.sound) {
         var snd = new Media(data.sound.substring(4));
         snd.play();
     }
 });

Should work in both background and foreground.

Member

macdonst commented Oct 1, 2015

@tmakaro Yeah, iOS assumes that the sound file is in root folder of your app. Using:

{
    "aps": {
        "alert": "test alarm", 
        "sound": "www/alarm.caf"
    }
}

push.on('notification', function (data) {
     if (data.sound) {
         var snd = new Media(data.sound.substring(4));
         snd.play();
     }
 });

Should work in both background and foreground.

@tmakaro

This comment has been minimized.

Show comment
Hide comment
@tmakaro

tmakaro Oct 1, 2015

@macdonst Yes it does. Thank you!

tmakaro commented Oct 1, 2015

@macdonst Yes it does. Thank you!

@tmakaro tmakaro closed this Oct 1, 2015

@lock

This comment has been minimized.

Show comment
Hide comment
@lock

lock bot Jun 5, 2018

This thread has been automatically locked.

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.