kingelessar
Lost but trying
Profile
Posts: 155
Reg: Mar 10, 2014
UK
6,500
05/15/14 02:57 AM (9 years ago)

If using custom URL scheme (iOS) and Scringo

For those like me who don't find this immediately obvious! <g> I'm a great fan of using a custom URL scheme in Xcode in order to interlink html docs. But I needed some help from Scringo support when I added Scringo to the app. You end up being asked to add a -(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url to appDelegate.m in both cases and I didn't know how one integrates the two. I simply pasted both codes and that didn't work. For Scringo you paste: -(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { return < span class="pun">[Scringo handleOpenURL:url]; } and for the custom URL scheme you paste: -(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { vipuk_appDelegate *appDelegate = (vipuk_appDelegate *) [[UIApplication sharedApplication]delegate]; [BT_debugger showIt:self theMessage:@"Tapped on a custom URL"]; // Check if we got a screen nickname from the URL to process NSString *loadScreenNickname = [url host]; BT_item *screenObjectToLoad = nil; if ( [loadScreenNickname length] > 1 ) {[BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"Nickname of screen to load: %@", loadScreenNickname]]; screenObjectToLoad = [appDelegate.rootApp getScreenDataByNickname:loadScreenNickname]; } else { [BT_debugger showIt:self theMessage:@"ScreenNickname to load is blank"]; return NO; } // Check if the Screen was found within the App's JSON data if ( screenObjectToLoad != nil ) {NSLog(@"loading screen:%@", screenObjectToLoad.itemId); [self.getViewController handleTapToLoadScreen:screenObjectToLoad theMenuItemData:nil]; } else { [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"URL Scheme error: %@", url]]; } return YES; } The solution was to add [Scringo handleOpenURL:url]; only to the custom URL code to make it: -(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { vipuk_appDelegate *appDelegate = (vipuk_appDelegate *) [[UIApplication sharedApplication]delegate]; [BT_debugger showIt:self theMessage:@"Tapped on a custom URL"]; //add scringo [Scringo handleOpenURL:url]; // Check if we got a screen nickname from the URL to process NSString *loadScreenNickname = [url host]; BT_item *screenObjectToLoad = nil; ...
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
05/15/14 08:34 AM (9 years ago)
Thank you, that solution is a keeper!
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.