1

I want the phone to vibrate more than once on incoming push notifications.

To realize this behavior I scheduled several text-less local notifications (after 1 second, 2 seconds, ...) in the application:didReceiveRemoteNotification:fetchCompletionHandler: method.

This works well on the device that I use for development and several other phones, but it doesn't work on all of them.

What can I do to make it work on all devices?

pinki
  • 902
  • 2
  • 12
  • 29

2 Answers2

0

Since iOS looks a how you app handles application:didReceiveRemoteNotification:fetchCompletionHandler: it may or may not call that method. If a user has disabled background updating then the method is never called.

Since you are misusing this API for something it is not intended there will be no way to make work on all devices.

rckoenes
  • 69,092
  • 8
  • 134
  • 166
  • So even if the user has enabled background updating, you cannot say if the method gets called? – pinki Apr 28 '14 at 12:16
  • Yes, first you app needs to have the background mode 'remote-notification' then iOS will monitor the usage the remote notification for battery drain: `More importantly, the system uses the elapsed time to calculate power usage and data costs for your app’s background downloads.` – rckoenes Apr 28 '14 at 12:21
  • The background mode is set in the capabilities tab and the "content-available" flag is set to 1 within the push notification's payload. The app needs only a few milliseconds to schedule the "empty" local notifications that trigger the vibrations. Does this increase the chance of getting the method called? – pinki Apr 28 '14 at 12:33
  • Since it is not meant for this there are only going to be maybe answers. Apple specifically mentions that you should use `NSURLSession` in this method so that it can determine if you are draining the battery. There might be some check done by the system to see if your app even does a call. But this is not described anywhere. Since your are **misusing** this API there is no guarantee that it will work. – rckoenes Apr 28 '14 at 12:41
0

If you want to phone to only vibrate on receipt of a push notification, you need to have a silent sound file in your application bundle, for example "silence.aif" ...

if you specify that sound file in the APS notification, the iOS device will "play" the silence.aif from your application bundle, but since the sound is silence, there is nothing to hear. However the notification vibration is still triggered :-)

Vizllx
  • 9,135
  • 1
  • 41
  • 79
  • I have a regular sound for the push notifications and a silent sound for local notifications. I'm still wondering why I don't receive the local notifications on all devices. – pinki Apr 28 '14 at 12:08