2012-04-08 2 views
0

저는 작고 간단한 iPhone 용 애플리케이션을 구축하고 있습니다. 그것이해야 할 일은 웹 사이트 링크를 표시하는 것입니다 (예, 정말로 그렇습니다). 하지만 사용자에게 앱의 링크를 클릭하도록 경고하기 위해 매주 지역 발사 알림이 필요합니다. 지금은 경험이별로 없기 때문에 어디서부터 시작해야할지 모르겠습니다. 나는 주변 검색 좀하고 로컬 알림을 반복하는 방법을 발견 : http://xebee.xebia.in/2011/04/13/local-notifications-in-iphone/. 하지만이 코드를 어디에 넣을 지조차 모릅니다. 보기 기반 응용 프로그램을 만들면, 위의 코드를 어떤 방법으로 넣을 수 있습니까? 누군가가 내가 할 수있는 것의 개요를 제공하거나 심지어 Google (키워드 등)에 대한 일부 사항을 제공 할 수 있고 나갈 수있는 경우 그걸 읽어라. 이 응용 프로그램은 필자 자신의 학습이 아니라 필연적으로 만들어 졌으므로 이제 끝내야합니다. 어떤 포인터 감사!반복적 인 지역 알림을 발생시키는 iPhone 앱 구축

답변

0

단일보기 템플릿이 가장 먼저 시작하는 것이 좋습니다. 로컬 알림은 사용하기가 매우 쉽습니다. 먼저 시작하는 방법은 작동 방식과 사용 방식을 이해하는 것입니다. 배치 한 시나리오는 지역 알림을 위해 올바르게 들립니다. 먼저 Apple's documentation을 살펴보세요. 이것이 어떻게 수행되는지에 대한 많은 예제가 있습니다.

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를 사용할 수 있습니다

2

를 사용하여이 알림을 예약합니다.

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  

    }