2014-11-23 1 views
0

내가 그 일을해야한다면 시스템이나 시스템을 조금 혼란스럽게합니다.iOS는 백그라운드에서 어떤 일이 발생했을 때 알림을 표시합니까?

iBeacon을 사용하면 앱이 백그라운드 일 때 또는 종료 될 때 해고되는 방법이 있습니다. 여기에 iPhone 홈 화면에 푸시 알림을 표시하는 코드를 작성하여 알려주고 싶습니다.

어떻게 그렇게 간단한 일을 할 수 있습니까?

//happens in background when user inside a place 
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region { 
    [self.locationManager startRangingBeaconsInRegion:self.beaconRegion]; 
    NSLog(@"***********************ENTER"); 

//here show notification ! 
+0

로컬 알림을 예약합니다. – nhgrif

+0

어떻게? 나는 그것의 간단한 것을 안다, 나는 다만 기울이지 않는다 google에 그것을 ... 찾아 내십시오 – Curnelious

답변

0

다음과 같이 시도해 볼 수 있습니다. 이렇게하면 설정된 날짜와 시간에 화재가 발생하도록 지역 알림을 예약합니다 (NSDate 및 메시지를 제공해야 함).

... 
NSDate *fireDate = // whatever date and time you want to fire the notification 
NSString alertMessage = @“Alert message!"; 
[self addNotification:fireDate mymessage:alertMessage]; 
... 


-(void)addNotification:(NSDate *)mydate mymessage:(NSString *)mymessage 
{ 
    UILocalNotification *localNotification = [[UILocalNotification alloc] init]; 
    localNotification.fireDate = mydate; 
    localNotification.alertBody = mymessage; 
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; 
} 
관련 문제