Get last 10 photos from iPhone using AssetLibrary, Corelocation deprecation issue on ios 6.1.3 -
app tries access photos phone library. works on ipod (5.1.something) iphone5 (6.1.4), simulators, crashes on iphone 4s(6.1.3).
all checks (location services, photo library access) there w.r.t ios version.
console log: : libmobilegestalt copysystemversiondictionaryvalue: not lookup releasetype system version dictionary
jul 31 12:03:00 abc's-iphone awdd[296] : corelocation: clclient deprecated. obsolete soon.
btw below code fetches last 10 photos photo library. if exist. before calling method check location made using [cllocationmanager authorizationstatus].
- (void) getrecentphotos { if(! onetimefetch) // prevent location delegate calling method. { onetimefetch = true; nslog(@"getrecentphotos"); recenpicscroll.userinteractionenabled = false; [self.recentpicsarr removeallobjects]; if ([[[uidevice currentdevice] systemversion] doublevalue] >= 6.0) { nslog(@"ios version 6.0 , above, need check photo access"); if ([alassetslibrary authorizationstatus] == alauthorizationstatusauthorized) { nslog(@"photo access allowed"); // execute code after loop ends. else return :). } else { recentpicview.hidden = true; nslog(@"please alllow photo access"); return; } } recentpicview.hidden = false; loadingai.hidden = false; alassetslibrary *al = [[alassetslibrary alloc] init]; [al enumerategroupswithtypes:alassetsgroupsavedphotos usingblock:^(alassetsgroup *group, bool *stop) { [group setassetsfilter:[alassetsfilter allphotos]]; [group enumerateassetsusingblock:^(alasset *asset, nsuinteger index, bool *stop) { if([group numberofassets] == 0) { recentpicview.hidden = true; return; } int startidx = [group numberofassets]- 10; // start 10th last if (asset) { //nslog(@"asset index: %d",index); alassetrepresentation *rep = [asset defaultrepresentation]; cgimageref imgref = [rep fullresolutionimage]; if(group.numberofassets > 10) // upto 10 { if(index >= startidx) { [self.recentpicsarr addobject:[uiimage imagewithcgimage:imgref]]; if(index == [group numberofassets] - 1) { [self addpicstoscrollv]; } } } else if (group.numberofassets <= 10) // less 10 photos { [self.recentpicsarr addobject:[uiimage imagewithcgimage:imgref]]; if(index + 1 == group.numberofassets) { [self addpicstoscrollv]; } } else { recentpicview.hidden = true; } } }]; } failureblock:^(nserror *error) { nslog(@"you must allow app fetch photos"); } ] ; } }
since alasset library requires location services enabled, couldn't ignore location check.
and since ios 6.0 user can prevent app accessing photo library assetlibrary authorisation required.
solution me use [self.locmgr stopupdatinglocation] in below delegate:
- (void)locationmanager:(cllocationmanager *)manager didchangeauthorizationstatus:(clauthorizationstatus)status { if(status == 1 || status == 2) { no_location_alert // user denied location. don't start activity fetching photos } else if (status == kclauthorizationstatusauthorized) { //start fetching fotos } else { // first time, when user hasn't made choice. leave blank. } [self.locmgr stopupdatinglocation]; // solution }
Comments
Post a Comment