簡體   English   中英

我的應用中的iOS鬧鍾功能

[英]iOS Alarm features in my app

我在iOS應用程序上工作,需要開發以下Alarm標准功能。

  1. 設置自定義音調(或靜音)
  2. 設定振動(是/否)
  3. 設置小睡(是/否和小睡時間)

我已經進行了研究,沒有發現任何幫助,首先我想知道這是否真的可能? iOS對這些功能有任何限制嗎? 如果有可能,請指導我,以便我進行探索。

提前感謝。

有可能做。 您將必須為此發布一個LocalNotification。 看一下這個帖子

要產生振動,可以使用AudioToolBox.framework。

AudioServicesPlayAlertSound(kSystemSoundID_Vibrate); AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

 //   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. 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM