gpt4 book ai didi

iphone - 创建有声音且无振动的 UILocalNotification

转载 作者:行者123 更新时间:2023-12-03 21:17:37 28 4
gpt4 key购买 nike

是否可以创建 UILocalNotification 播放自定义声音但不振动手机?

编辑:这是我用来创建 UILocalNotification 的代码,它可以工作,但会振动手机。我不想让手机振动,但我想播放声音。

UILocalNotification *notif = [[UILocalNotification alloc] init];
notif.fireDate = [NSDate dateWithTimeIntervalSinceNow:seconds];
notif.timeZone = [NSTimeZone defaultTimeZone];
//notif.alertBody = alertMessage;
//notif.alertAction = @"Show me";
notif.soundName = soundName;
notif.applicationIconBadgeNumber = 0;
NSDictionary *userDict = [NSDictionary dictionaryWithObject:soundName forKey:kCurrentSound];
notif.userInfo = userDict;
[[UIApplication sharedApplication] scheduleLocalNotification:notif];
[notif release];

最佳答案

不幸的是,如果您想要声音,则无法禁用振动,除非用户已进入“常规设置”并自行禁用振动。

关于iphone - 创建有声音且无振动的 UILocalNotification,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9450791/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com