I am wondering how to send a Push Notification with NO sound.
From Apple's website:
The sound in this file is played as an alert. If the sound file
doesn’t exist or default is specified as the value, the default alert
sound is played.
This says that if I use "default" for the sound file or if I specify a sound file that does not exist, it will play the default alert sound.
But it does specifically state how to have no sound... If I just do not include a sound in the payload (leave it out), will this mean that there will be no sound played?
Thanks
If I just do not include a sound in the payload (leave it out), will this mean that there will be no sound played?
That's right. Just don't include sound
in the payload. Or, don't even register for sound notification type if you're never going to want to play sounds.
You should configure your App to receive the type of PN that you wish to accept, there are three options:
- Display a short text message
- Play a brief sound
- Set a number in a badge on the app's icon
You may use these three in any combination that you see fit, now all you need to do in your App is to registerForRemoteNotificationTypes as follows:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
// Let the device know we want to receive push notifications
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
return YES;
}
Select the appropriate option(s) in your case, once the app starts and registers for Push Notifications, a message will popup asking the user whether or not to accept Push Notifications.
When registering for notifications you do something like this i'm guessing?
[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound];
just don't include UIRemoteNotificationTypeSound.