Notifications ibeacons通知警报未显示
我创建了一个应用程序,它使用信标区域和位置管理器通知用户是否在某个区域内,并根据信标区域标识符接收通知。 我把Notifications ibeacons通知警报未显示,notifications,ios8,xcode6,ibeacon,Notifications,Ios8,Xcode6,Ibeacon,我创建了一个应用程序,它使用信标区域和位置管理器通知用户是否在某个区域内,并根据信标区域标识符接收通知。 我把 NSLocationAlwaysUsageDescription 在应用程序的plist中,我将 if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) { types = UIUserNotificationTypeAlert | UIUserNotificati
NSLocationAlwaysUsageDescription
在应用程序的plist中,我将
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
types = UIUserNotificationTypeAlert | UIUserNotificationTypeSound | UIUserNotificationTypeBadge ;
UIUserNotificationSettings *mySettings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
[[UIApplication sharedApplication]registerUserNotificationSettings:mySettings];
}
及
在应用程序代理的didFinishLaunchingWithOptions中:
应用程序中同时显示通知和位置服务,要求用户授予接收通知和始终使用位置服务的权限。当用户同意这两种方式时,我进入设置/应用程序名称,我可以看到位置管理器和通知是允许的。但当应用程序进入信标区域时,仍然不会出现通知警报
这是我在app委托中使用的代码,用于在ios8中显示通知
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
notification.alertBody = @"Want to play checkers.";
AlertView= [[UIAlertView alloc] initWithTitle:@"Play a Game?"
message:notification.alertBody
delegate:NULL
cancelButtonTitle:@"OK"
otherButtonTitles:@"CANCEL", nil];
[AlertView show];
if ([notification.alertBody isEqualToString:@"Want to play Chess?"]) {
}
然后我得到一个警报,上面描述了尸体。这是一个通用警报,对我没有好处。我想使用我编写的警报,以及在IOs7下使用locationNotifications的警报,如
-(void)locationManager:(CLLocationManager*)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion*)region{
UILocalNotification *notification = [[UILocalNotification alloc]init];
if(state == CLRegionStateInside){
if ([region.identifier isEqualToString:@"com.checkers.bluetooth"]) {
NSLog(@"beaconRegion2proximityUUID;%@",beaconRegion2.proximityUUID);
[UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{inviteCheckers.frame = CGRectMake(147,55,20,20); } completion:^ (BOOL completed) {} ];
notification.alertBody = @"Want to play checkers.";
AlertView= [[UIAlertView alloc] initWithTitle:@"Play a Game?"
message:notification.alertBody
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:@"CANCEL", nil];
[AlertView show];
identifierString = region.identifier;
/* NSLog(@"identity:%@",identifierString);*/
messageString2 = @"checkers";
}
if ([region.identifier isEqualToString:@"com.chess.bluetooth"]) {
[UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{inviteChess.frame = CGRectMake(147,108,20,20); } completion:^ (BOOL completed) {} ];
notification.alertBody = @"Want to play Chess?";
AlertView= [[UIAlertView alloc] initWithTitle:@"Play a Game?"
message:notification.alertBody
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:@"CANCEL", nil];
[AlertView show];
identifierString = region.identifier;
messageString2 = @"chess";
/* NSLog(@"identity:%@",identifierString);*/
}
我想使用这个代码
-(void) locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status{
BOOL canUseLocationNotifications = (status == kCLAuthorizationStatusAuthorizedAlways);
if (canUseLocationNotifications){
[self startShowingLocationNotifications];
}
}
为了让我编写的locationNotifications显示出来,但当我在app delegate中编写此代码时,我会收到错误No Visible@interface for'AppDelegate'声明选择器“startShowingLocationNotifications”
我确信这是我需要做的,以便在ios8中显示正确的通知,但我不知道如何做到这一点。我在互联网上搜索了一下,结果一无所获。请有人帮助我将此代码放到正确的位置以获得正确的通知。检查您是否已在应用程序的-Info.plist文件中为“nsLocationAlwaysSusageDescription”提供了值。如果没有此选项,权限警报视图将不会显示,权限设置也将不正确。是的,我已完成此操作。如何消除开始显示本地通知时出现的错误?请参阅,我已将NSLocationManager使用的方式放置在我的plist中,并且已放置[locationManager requestAlwaysAuthorization];在我看来,我已经收到了这项工作的通知部分,并将张贴我所做的编辑我的原始文章不久。但是我仍然有问题,所以我将发布一个新问题。
-(void) locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status{
BOOL canUseLocationNotifications = (status == kCLAuthorizationStatusAuthorizedAlways);
if (canUseLocationNotifications){
[self startShowingLocationNotifications];
}
}