从didEnterRegion触发时的警报通知(本地)奇怪的行为

时间:2014-09-30 02:56:22

标签: ios uilocalnotification ibeacon clregion

当我今天测试我的应用程序时,我意识到当从didEnterRegion触发通知时没有设法触发下面的代码..(我将通知设置为警报通知)

UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (notification)
{
//Set rootViewController.
}

但是,当我将通知样式更改为横幅样式时。上面的代码确实触发了

输入区域代码:

-(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region{

[self sendLocalNotificationForReqgionConfirmationWithText:[NSString stringWithFormat:@"Check out %@ latest offer today!!", region.identifier]forBeaconRegion:(CLBeaconRegion *)region];}


-(void)sendLocalNotificationForReqgionConfirmationWithText:(NSString *)text forBeaconRegion: (CLBeaconRegion *)region {
NSNumber *testValue = [NSNumber numberWithInt:100];
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
localNotif.fireDate = [NSDate dateWithTimeInterval:1.0 sinceDate:[NSDate date]];
localNotif.timeZone = [NSTimeZone defaultTimeZone];
localNotif.alertBody = @"test";
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 1;
localNotif.userInfo = @{@"Major": testValue };

[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[_locationManager startRangingBeaconsInRegion:region];}

那么,任何人都可以告诉我错误是什么吗?或者至少为我提供一些方向。谢谢你的时间。

0 个答案:

没有答案