如果我必须这样做,或者系统:
,我有点困惑使用iBeacon时,有一种方法在app处于后台或关闭时触发。 在那里,我想编写代码,在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 :(得分: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];
}