问题
I'd like to schedule a local notification on the phone. When the phone is locked and the watch is sleep I'd like the notification to vibrate the watch but not play a sound. Is this possible? My code below runs on the iphone to schedule the notification but don't know how to suppress the sound when playing on the watch.
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.fireDate = [[NSDate date] dateByAddingTimeInterval:60];
notification.alertTitle = [NSString stringWithFormat:@"Hi # %d", i];
notification.alertBody = @"Hello!";
notification.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
回答1:
You can decide to not set the sound name and not opt in to use sounds in your notification settings. You can then make your own vibration behavior if there is not already one.
来源:https://stackoverflow.com/questions/34863755/can-a-local-notification-only-vibrate-the-apple-watch-and-not-play-a-sound