2012-04-08 4 views
0

私はiPhoneのための小さくてシンプルなアプリケーションを構築しています(私はそれほど経験はありません)。それがしなければならないことは、ウェブサイトへのリンクを表示することです(本当にそうです)。しかし、私は毎週あなたがアプリ内のリンクをクリックするように警告するために毎週火を送るためのローカル通知が必要です。今私はあまり経験していないので、どこから始めたらいいのか分かりません。私は周りにgoogledとローカル通知を繰り返す方法を見つけた:http://xebee.xebia.in/2011/04/13/local-notifications-in-iphone/。しかし、私はこのコードをどこに置くべきか知りませんか?私はビューベースのアプリケーションを作成するかどうかは、上記のコードを入れてどのような方法です。誰かが私に何をすることができますか、または私にいくつかのものを(キーワードなど)私にいくつかのものを与えることができる概要を与えることができると私は行くことができますそれを読んでください。このアプリは必然的に構築されているので、私自身の学習ではないので、ただ完了させる必要があります。任意のポインタが評価!繰り返しのローカル通知を発生させるiPhoneアプリを構築する

答えて

0

最初に単一のビューテンプレートを使用するのが最善の方法でしょう。ローカル通知は非常に使いやすいです。まず、どのように動作し、どのように使用するべきかを理解することです。あなたが配置したシナリオは、地元の通知のために適切に聞こえます。まずApple's documentationを見てください。これがどのように行われるかの例がたくさんあります。

2

は、通知をスケジュールするためにこれを使用します。

UILocalNotification *localNotification = [[UILocalNotification alloc] init]; 

    //setting the fire dat of the local notification. Put the date you want the notification to be sent 
    localNotification.fireDate = [[[NSDate alloc] init] autorelease]; 

    //setting the time zone 
    localNotification.timeZone = [NSTimeZone defaultTimeZone]; 

    //setting the message to display 
    localNotification.alertBody = @"Notification Body"; 

    //default notification sound 
    localNotification.soundName = UILocalNotificationDefaultSoundName; 


    localNotification.alertAction = @"Action!"; 

    //Saving regionIndex and searchIndex 
    NSDictionary *userInfo = [[NSDictionary alloc] initWithObjectsAndKeys:@"value", @"key", nil]; 
    localNotification.userInfo = userInfo; 
    [userInfo release]; 

    //schedule a notification at its specified time with the help of the app delegate 
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];  
    [localNotification release]; 

そして、ユーザがアプリケーションをロードするたびに、あなたはこの次の週の通知がすでに予定されているかどうかを確認するためにscheduledLocalNotificationsを使用することができます。

NSArray *notifications = [NSArray arrayWithArray:[[UIApplication sharedApplication] scheduledLocalNotifications]]; 
    for (UILocalNotification *notification in notifications) { 
     NSDictionary *userInfo = notification.userInfo; 
     NSdate *date = notification.fireDate; 

     // Here is where you can check if the notification was already scheduled  

    } 
関連する問題