IOS Push Notifications - how to specify an alert and icon without sound?

I am wondering how to send push notification without sound.

From the Apple website :

Sound in this file is played as a warning. If the sound file does not exist or the default value is specified as the value, a warning is given by default to the sound.

This suggests that if I use "default" for a sound file or if I specify a sound file that does not exist, it will play a warning sound by default.

But it specifically says how to not have sound ... If I just do not include the sound in the payload (leave it alone), will this mean that the sound will not play?

thanks

+1
source share
3 answers

If I just do not include the sound in the payload (leave it), will this mean that the sound will not play?

It is right. Just don't include sound in the payload. Or do not even register for the type of sound notification if you never want to play sounds.

+4
source

You need to configure the application to get the type of PN that you want to accept, there are three options:

  • Display a short text message
  • Play short sound
  • Set the number in the icon on the application icon

You can use these three in any combination that you consider necessary, now all you need to do in your application is register the RemoteNotificationTypes types 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; } 

Choose the appropriate option in your case, as soon as the application starts and registers for push notifications, a message appears asking the user whether to accept push push notifications.

0
source

When registering for notifications, you do something like this, I guess?

 [application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound]; 

just don't include UIRemoteNotificationTypeSound.

-one
source

Source: https://habr.com/ru/post/1493388/


All Articles