Can a local notification only vibrate the apple watch and not play a sound?

匆匆过客 提交于 2020-01-04 05:37:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!