objective c - CLLocation services. Added plist keys and request permission, yet still not working for IOS 8 -


i've checked other topics on stack overflow , done same changes. apple docs doesn't seem have i've missed either.

copied plist file:

<?xml version="1.0" encoding="utf-8"?> <!doctype plist public "-//apple//dtd plist 1.0//en" "http://www.apple.com/dtds/propertylist-1.0.dtd"> <plist version="1.0"> <dict>     ...     <key>nslocationusagedescription</key>     <string>used finding users in area. &quot;stealth mode&quot; can used if not users see location on map</string>     <key>nslocationwheninuseusagedescription</key>     <string>used finding users in area. &quot;stealth mode&quot; can used if not users see location on map</string>     ... </dict> </plist> 

my code:

+(asyncbackgroundupdatemanager*)getinstance {     if (instance == nil)     {         instance = [[asyncbackgroundupdatemanager alloc] init];     }      return instance; }  -(id)init {     if (instance != nil)     {         nslog(@"warning: should not call init on asyncbackgroundupdatemanager, should use static \"getinstance\" method.@");     }      self = [super init];     if (self)     {         if ([cllocationmanager locationservicesenabled])         {             if (locmanager == nil)             {                 locmanager = [[cllocationmanager alloc] init];             }              locmanager.delegate = self;             locmanager.desiredaccuracy = kcllocationaccuracyhundredmeters;             locmanager.distancefilter = 100;//meters         }         else         {             nslog(@"location not enabled");         }     }      return self; }   // ------------------------------------------------------------- // controlling updating process // -------------------------------------------------------------  -(void)start {     //get locations permission     if ([locmanager respondstoselector:@selector(requestwheninuseauthorization)]) {         [locmanager requestwheninuseauthorization];         switch ([cllocationmanager authorizationstatus]) {             case kclauthorizationstatusdenied:                 nslog(@"location services not allowed");                 break;             case kclauthorizationstatusnotdetermined:                 nslog(@"location services undecided");                 break;             case kclauthorizationstatusauthorizedwheninuse:             case kclauthorizationstatusauthorized:                 nslog(@"location services allowed");                 break;             case kclauthorizationstatusrestricted:                 nslog(@"location services restricted?");                 break;         }      }     [locmanager startupdatinglocation];     thetimer = [nstimer scheduledtimerwithtimeinterval:120 target:self selector:@selector(doupdate) userinfo:nil repeats:yes]; } 

called line:

[[asyncbackgroundupdatemanager getinstance] start]; 

i've verified location manager initialized via breakpointing on the alloc/init line.

i've verified requestwheninuseauthorization called breakpointing on line.

i'm never prompted location services, , breakpoint in did update location never called.

in device's settings, app doesn't appear request permissions location.

this outputed: location services undecided

edit:

from comments: start method called in main thread device i'm running on has location services enabled, , running ios 8. worked prior ios 8.

edit:

when executing code provided user ios in new testing view controller same results. here screenshot show call being called. (i stepped debugger line, starting can see breakpoint) shows line called

if getting 'kclauthorizationstatusnotdetermined status location services have not been set app. need permission before calling startupdatinglocation

try this:

//request permissions if([mylocationmanager respondstoselector:@selector(requestwheninuseauthorization)]){     //ios 8 , above permission request     //get current status     clauthorizationstatus currentstatus=[cllocationmanager authorizationstatus];      //if undetermined, ask permission     if (currentstatus == (kclauthorizationstatusnotdetermined)) {         //request permission         [mylocationmanager requestwheninuseauthorization];     } } 

Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -