本地通知可以只震动苹果手表而不播放声音吗? [英] Can a local notification only vibrate the apple watch and not play a sound?

查看:73
本文介绍了本地通知可以只震动苹果手表而不播放声音吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在电话上安排本地通知.当手机锁定且手表处于睡眠状态时,我希望通知震动手表但不播放声音.这可能吗?我下面的代码在 iphone 上运行以安排通知,但不知道如何在手表上播放时抑制声音.

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];

推荐答案

您可以决定不设置声音名称,也不选择在通知设置中使用声音.如果还没有振动行为,您可以创建自己的振动行为.

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.

这篇关于本地通知可以只震动苹果手表而不播放声音吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆