Local notification sound and badge.

Hi  :smiley:

 

I have a few problem with the local notifications on iOS:

 

My local notifications are “working”, but I cant seem to change the notification sound on iOS. It always plays the “trippel tone” even if I try to change it to “beep.caf” and other native iOS alert sounds. I have also tried to change all the sounds in my iPod´s settings with no luck. Sometimes the sound won´t even play  :unsure:

How can I choose the sound that plays when the local notification pops up?

 

 

When I set the badge to 1 in the notification options, the badge displays 1. But when I set the badge to 0 in the notification options when 1 is displayed, nothing happends. 

 

 

Help me please  :rolleyes:

Can you post your code where you’re setting your badge and sound information?

 Hi Rob! I dont know how to post code but here it is:

else    --if iOS

         

        local optionsIosBadgeTwo = {

            alert = alertText,

            badge = 2,

            sound = “alarm.caf”,

            custom = { msg = “Alarm” }

        }

         

        local optionsIosBadgeOne = {

            alert = alertText,

            badge = 1,

            sound = “alarm.caf”,

            custom = { msg = “Alarm” }

        }

        local optionsIosBadgeNull = {

            alert = alertText,

            badge = 0,

            sound = “alarm.caf”,

            custom = { msg = “Alarm” }

        }

        if myLibrary.data3 == 1 then --Only one notification

           system.scheduleNotification( timeToNotification, optionsIosBadgeNull )

        else --3 notifications

            system.scheduleNotification( timeToNotification, optionsIosBadgeOne )

           system.scheduleNotification( timeToNotification + 3600, optionsIosBadgeTwo )

            system.scheduleNotification( timeToNotification + (3600*2), optionsIosBadgeNull )

        end

*The three notifications are the problem. I´m hoping that the last one should remove the badge.

*I can use whatever.caf but the sound won´t change :frowning:

You can’t use the set to 0 to clear a previous badge.  It just says for this notification don’t set a badge.  You can use:

native.setProperty( “applicationIconBadgeNumber”, 0 )

to reset an existing badge (I think it works for local, I know it does for push).

As for the sounds, do you have the app open when the notification goes off?  If so the sound won’t play.

Rob

Oh thanks Rob  ^_^  So there is no way to remove the badge with a notification. That explains alot.

I´m using native.setProperty( “applicationIconBadgeNumber”, 0 ) when the app is starting so that removes the badge, but I was hoping a notification could get rid of it.

The sound won´t always play when the app is closed. It happens rarely but still it makes me sad  :mellow: 

Is there a way to choose what native sound to play, or is the only option “alarm.caf”? I can´t find information about that.

-Tom

You should be able to include any .caf file in your resource folder (where your main.lua lives) and it will play it.  It has to be a CAF file and I don’t think you can put it in a folder.

Oh nice! I will try that.

Thanx for answering all of my questions Rob :smiley:

I will post an update if I manage to play my own .CAF file.

-Tom

It worked! My custom .caf sound was played :smiley:

I couldnt be happier :smiley:

Thanx again :wink:

Good!

Can you post your code where you’re setting your badge and sound information?

 Hi Rob! I dont know how to post code but here it is:

else    --if iOS

         

        local optionsIosBadgeTwo = {

            alert = alertText,

            badge = 2,

            sound = “alarm.caf”,

            custom = { msg = “Alarm” }

        }

         

        local optionsIosBadgeOne = {

            alert = alertText,

            badge = 1,

            sound = “alarm.caf”,

            custom = { msg = “Alarm” }

        }

        local optionsIosBadgeNull = {

            alert = alertText,

            badge = 0,

            sound = “alarm.caf”,

            custom = { msg = “Alarm” }

        }

        if myLibrary.data3 == 1 then --Only one notification

           system.scheduleNotification( timeToNotification, optionsIosBadgeNull )

        else --3 notifications

            system.scheduleNotification( timeToNotification, optionsIosBadgeOne )

           system.scheduleNotification( timeToNotification + 3600, optionsIosBadgeTwo )

            system.scheduleNotification( timeToNotification + (3600*2), optionsIosBadgeNull )

        end

*The three notifications are the problem. I´m hoping that the last one should remove the badge.

*I can use whatever.caf but the sound won´t change :frowning:

You can’t use the set to 0 to clear a previous badge.  It just says for this notification don’t set a badge.  You can use:

native.setProperty( “applicationIconBadgeNumber”, 0 )

to reset an existing badge (I think it works for local, I know it does for push).

As for the sounds, do you have the app open when the notification goes off?  If so the sound won’t play.

Rob

Oh thanks Rob  ^_^  So there is no way to remove the badge with a notification. That explains alot.

I´m using native.setProperty( “applicationIconBadgeNumber”, 0 ) when the app is starting so that removes the badge, but I was hoping a notification could get rid of it.

The sound won´t always play when the app is closed. It happens rarely but still it makes me sad  :mellow: 

Is there a way to choose what native sound to play, or is the only option “alarm.caf”? I can´t find information about that.

-Tom

You should be able to include any .caf file in your resource folder (where your main.lua lives) and it will play it.  It has to be a CAF file and I don’t think you can put it in a folder.

Oh nice! I will try that.

Thanx for answering all of my questions Rob :smiley:

I will post an update if I manage to play my own .CAF file.

-Tom

It worked! My custom .caf sound was played :smiley:

I couldnt be happier :smiley:

Thanx again :wink:

Good!