0

我正在iOS开发需要开发以下警报标准功能的应用程序。

  1. 设置自定义音调(或静音)
  2. 设置振动(是/否)
  3. 设置贪睡(是/否和贪睡持续时间)

我做了研究,发现没有任何帮助,首先我想知道这真的可能吗?iOS 对这些功能有什么限制吗?如果可能,请指导我,以便我可以探索。

提前谢谢。

4

2 回答 2

0
 //   Yes it is possible ,for alarm you have to use UILocalNotification class 
     For example :

    UILocalNotification *localNotification = [[UILocalNotification alloc] init];
    //---set the notification to go off in 10 seconds time---
    localNotification.fireDate =[[NSDate alloc] initWithTimeIntervalSinceNow:10];
    //---the message to display for the alert---
    localNotification.alertBody = message.text; localNotification.applicationIconBadgeNumber = 1;
    //---uses the default sound---
    localNotification.soundName = UILocalNotificationDefaultSoundName; //---title for the button to display---
    localNotification.alertAction = @”View Details”;

    //---schedule the notification---
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

    //---display the notification now---
    [[UIApplication sharedApplication] presentLocalNotificationNow:localNotification];

    - (void) application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@”Inside
    application:didReceiveLocalNotification:”
    message:notification.alertBody

    delegate:self cancelButtonTitle:@”OK” otherButtonTitles:nil];

    [alert show];
    [alert release]; }

//application:didReceiveLocalNotification: method is also called when the
application is running and the local notification is fired. 
于 2013-07-26T09:51:13.293 回答
0

这是可能的。您必须为其发布 LocalNotification。看看这个帖子

要创建振动,您可以使用 AudioToolBox.framework。

AudioServicesPlayAlertSound(kSystemSoundID_Vibrate); AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

于 2013-07-26T09:38:52.747 回答