ios8 - ibeacons notification alerts not showing up -
i have created app uses beacon regions , location manager notify users if inside region , receive notifications dependent upon beacon region identifier. have put
nslocationalwaysusagedescription
in app's plist , have put
if ([application respondstoselector:@selector(registerusernotificationsettings:)]) { types = uiusernotificationtypealert | uiusernotificationtypesound | uiusernotificationtypebadge ; uiusernotificationsettings *mysettings = [uiusernotificationsettings settingsfortypes:types categories:nil]; [[uiapplication sharedapplication]registerusernotificationsettings:mysettings]; }
and
self.locationmanager = [[cllocationmanager alloc] init]; [locationmanager requestalwaysauthorization]; locationmanager.delegate = self;
in app delegate's didfinishlaunchingwithoptions:
both notification , location services show in app ask users give permission receive notifications , use location services always. when user agrees both , go settings/ app's name can see location manager , notifications allow. still no notification alerts appear when app enters beacon region.
this code used in app delegate have notification appear in ios8
-(void)application:(uiapplication *)application didreceivelocalnotification:(uilocalnotification *)notification { notification.alertbody = @"want play checkers."; alertview= [[uialertview alloc] initwithtitle:@"play game?" message:notification.alertbody delegate:null cancelbuttontitle:@"ok" otherbuttontitles:@"cancel", nil]; [alertview show]; if ([notification.alertbody isequaltostring:@"want play chess?"]) { }
then alert has body described above. generic alert , me no good. want use alerts have written , worked under ios7 using 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 play checkers."; alertview= [[uialertview alloc] initwithtitle:@"play 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 play chess?"; alertview= [[uialertview alloc] initwithtitle:@"play game?" message:notification.alertbody delegate:self cancelbuttontitle:@"ok" otherbuttontitles:@"cancel", nil]; [alertview show]; identifierstring = region.identifier; messagestring2 = @"chess"; /* nslog(@"identity:%@",identifierstring);*/ }
i use code
-(void) locationmanager:(cllocationmanager *)manager didchangeauthorizationstatus:(clauthorizationstatus)status{ bool canuselocationnotifications = (status == kclauthorizationstatusauthorizedalways); if (canuselocationnotifications){ [self startshowinglocationnotifications]; } }
to have locationnotifications have written show when write code in app delegate error no visible @interface 'appdelegate" declares thje selector"startshowinglocationnotifications'
i'm sure need have correct notifications show in ios8 don't know how it. have searched internet no avail. can please me put code correct place right notifications.
check have supplied value "nslocationalwaysusagedescription" in app's -info.plist file. without permissions alert view won't shown , permissions won't set properly.
Comments
Post a Comment