简体   繁体   中英

Create UILocalNotification with sound and no vibration

Is it possible to create UILocalNotification playing a custom sound but not vibrate the phone?

EDIT: this is the code I used to create UILocalNotification, it works but it vibrates the phone. I don't want the phone to vibrate but I want to play a sound.

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

不幸的是,如果您想发出声音,除非用户进入“常规设置”并自己禁用振动,否则就不能禁用振动。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM