ios - Handling Dropbox authentication response -
ios - Handling Dropbox authentication response -
dropbox documentation explains default response authentication gets fired appdelegate.m how create same fire own class's delegate?
- (bool)application:(uiapplication *)app openurl:(nsurl *)url sourceapplication:(nsstring *)source annotation:(id)annotation { if ([[dbsession sharedsession] handleopenurl:url]) { if ([[dbsession sharedsession] islinked]) { nslog(@"app linked successfully!"); // @ point can start making api calls } homecoming yes; } // add together whatever other url handling code app requires here homecoming no; }
in info plist url type --> in url schemes add together db-yourappkey method called.
this method getting called automatically. hope created app dropbox developer site , appkey , appsecret. utilize code in app delegate nsstring* appkey = @"";
nsstring* appsecret = @""; nsstring *root = kdbrootdropbox; nsstring* errormsg = nil; if ([appkey rangeofcharacterfromset:[[nscharacterset alphanumericcharacterset] invertedset]].location != nsnotfound) { errormsg = @"make sure set app key correctly in dbrouletteappdelegate.m"; } else if ([appsecret rangeofcharacterfromset:[[nscharacterset alphanumericcharacterset] invertedset]].location != nsnotfound) { errormsg = @"make sure set app secret correctly in dbrouletteappdelegate.m"; } else if ([root length] == 0) { errormsg = @"set root utilize either app folder of total dropbox"; } else { nsstring *plistpath = [[nsbundle mainbundle] pathforresource:@"info" oftype:@"plist"]; nsdata *plistdata = [nsdata datawithcontentsoffile:plistpath]; nsdictionary *loadedplist = [nspropertylistserialization propertylistfromdata:plistdata mutabilityoption:0 format:null errordescription:null]; nsstring *scheme = [[[[loadedplist objectforkey:@"cfbundleurltypes"] objectatindex:0] objectforkey:@"cfbundleurlschemes"] objectatindex:0]; if ([scheme isequal:@"db-app_key"]) { errormsg = @"set url scheme correctly in dbroulette-info.plist"; } } dbsession* session = [[dbsession alloc] initwithappkey:appkey appsecret:appsecret root:root]; session.delegate = self; // dbsessiondelegate methods allow handle re-authenticating [dbsession setsharedsession:session]; [dbrequest setnetworkrequestdelegate:self]; // [[dbsession sharedsession]unlinkall]; if ([[dbsession sharedsession] islinked]) { isaccountfordropbox = yes; } else{ isaccountfordropbox = no; }
//after using open url phone call automatically.
ios dropbox-api
Comments
Post a Comment