1
votes

Below is my request notification code

if #available(iOS 10, *) {
        UNUserNotificationCenter.current().requestAuthorization(options:[.badge, .alert, .sound]){ (granted, error) in }
        application.registerForRemoteNotifications()
    }

I have asked for sound, alert, and badge permissions from user in notification. I also went through the link below regarding the push notification vibration.

vibrate in push notification

My question is push notification vibration when the app is closed is handled by app or it's the payload which makes iPhone vibrate.

Is it possible to handle vibration of iPhone from push notification, like sound key in payload of push notification or is there any other way to control push vibration?

Thanks in advance

2

2 Answers

1
votes

You can actually control the vibration within the payload by specifying the sound. If you are specifying your own sound, there might be not vibration but if you just take the default sound, the device will vibrate!

Example payload:

{
    "aps" : {
        "alert" : "You got your emails.",
        "badge" : 9,
        "sound" : "bingbong.aiff" // or set this to the default sound
    }
}
1
votes

You can't.

To trigger a vibration on the phone you need:

  • In your payload you need sound field under aps key
  • The device needs to have vibration enabled.

Obviously you can't control the vibration of a phone from the payload