Breaking News
Home / iOS / iOS Snippets / How to make iPhone vibrate on recieving Push Notification?

How to make iPhone vibrate on recieving Push Notification?

Snippet

When the push notification is received, the didReceiveRemoteNotification method of the App Delegate is called and one can make the phone vibrate invoking the AudioServicesPlaySystemSound method.

  1. /**
  2.  * Remote Notification Received while application was open.
  3.  */
  4. (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
  5.         #if !TARGET_IPHONE_SIMULATOR
  6.         NSString *sound = [apsInfo objectForKey:@“sound”];
  7.         NSLog(@“Received Push Sound: %@”, sound);
  8.         AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
  9.         #endif
  10. }
[pb_builder]

Check Also

EKCalendar – That account does not allow calendars to be added or removed

Usecase When I am trying to create a new Calendar programmatically using the EventKit API …

Advertisment ad adsense adlogger