Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 3    Views: 114

Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
11/06/12 02:19 PM (13 years ago)

Custom URL scheme help David

I'm ready to explode with cutomURL scheme I have created the custom url scheme myapp:// what I want to do is launch a hidden/secret screen by calling myapp://secret I've found the code to parse the url - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { NSLog(@"url recieved: %@", url); NSLog(@"query string: %@", [url query]); NSLog(@"host: %@", [url host]); NSLog(@"url path: %@", [url path]); NSDictionary *dict = [self parseQueryString:[url query]]; NSLog(@"query dict: %@", dict); return YES; } - (NSDictionary *)parseQueryString:(NSString *)query { NSMutableDictionary *dict = [[[NSMutableDictionary alloc] initWithCapacity:6] autorelease]; NSArray *pairs = [query componentsSeparatedByString:@"&"]; for (NSString *pair in pairs) { NSArray *elements = [pair componentsSeparatedByString:@"="]; NSString *key = [[elements objectAtIndex:0] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSString *val = [[elements objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; [dict setObject:val forKey:key]; } return dict; } Where do I put the code to make the secret screen appear instead of the normal screen. This secret screen will be found from within the app so it only has to be in the applicationbecomeactive method. What is the code??? It's drivong me bonkers this code could really make the augmented reality app because we all love finding secrets. Hope this makes sense. Hellllppppppp
 
baywebnz
Aspiring developer
Profile
Posts: 92
Reg: Oct 25, 2010
location unknow...
920
like
11/06/12 03:41 PM (13 years ago)
Hey Kittsy! Try this (Change values as needed): if ([request.URL.absoluteString isEqualToString:@"myapp://secret"]){ //appDelegate your_appDelegate *appDelegate = (your_appDelegate *)[[UIApplication sharedApplication] delegate]; //load new screen BT_item *mynextScreen = [appDelegate.rootApp getScreenDataByItemId:@"screen id here"]; //load next screen if it's not nil [BT_viewControllerManager handleTapToLoadScreen:[self screenData]:nil:mynextScreen]; } This needs to be added below here: -(BOOL)webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType{ I haven't tested this but should work. Hope this helps!
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
11/07/12 02:43 AM (13 years ago)
I've looked at that code and tried to tweak it. Unfortunately for this to work it has to be put in the appdelegate file. It's not the custom URL screen that is getting used. It will be called from a framework that I can't amend otherwise that would probably work. This line is the key - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
 
baywebnz
Aspiring developer
Profile
Posts: 92
Reg: Oct 25, 2010
location unknow...
920
like
11/07/12 04:33 PM (13 years ago)
Oh, sorry - I misread! Thought you meant the Custom URL screen, i'm not sure on that one i'm afraid.
 

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.