0

当我今天测试我的应用程序时,我意识到当从 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];}

那么,谁能告诉我错误是什么?或者至少给我一些方向。谢谢你的时间。

4

0 回答 0