Closed sahotataran closed 8 years ago
Hi, im stuck with the same issue...app starts at cold start but the handler is never called...can anybody help me?¿ Cordova-Ios: 3.92 Custom-URL-scheme: 4.1.5 cordova CLI: 5.3.1
Please help!
If you want anybody to step in and help it will be vital to provide them your xcode project.
Hi Eddy, the full Xcode project?¿?¿ could i send it 2 your email?¿¿
If it's easy for folks to reproduce the problem then you're more likely to get help. So if you share /platforms/ios and folks can simply open it in xcode and deploy on a device then that's awesome.
Please share a link to it here so others may help.
Hi Eddy, here is my platform/ios code https://www.wetransfer.com/downloads/1ae336ecbeb4280dcf99e069ce00fd2320160226122236/f1996ddcf1772d5f8063d05b2463d6ba20160226122236/9ca2b1 thanks
Hi Eddy and cgcalera
after struggling and doing hit and trial i managed to get it working
by overriding openUrl method in my AppDelegate.m
-(BOOL) openURL:(NSURL *) url
{
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPageDidLoadNotification object:url]];
return YES;
}
i also added
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
to
- (BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation
and now everything works fine
Hi Sahotataran, i am not able to make it work.... ive overwritten openURL methon on appDelegate.m adding: -(BOOL) openURL:(NSURL *) url { [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]]; [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPageDidLoadNotification object:url]];
return YES; }
but i didnt have to add [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]]; to - (BOOL)application:(UIApplication)application openURL:(NSURL)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation because its already exist there.
Could you please send me the appDelegate.m and all the files you had to modify?¿
Thanks a lot!
Sorry Cgcalera
those were my only changes and only differences
making those changes the handleOpenUrl started firing for me for all the cases - cold start and warm start
this is my appDelegate.m....is it right?¿
/* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */
// // AppDelegate.m // BucmiApp // // Created by _FULLUSERNAME_ on _DATE_. // Copyright _ORGANIZATIONNAME_ _YEAR_. All rights reserved. //
@implementation AppDelegate
@synthesize window, viewController;
(id)init { /\ If you need to do any extra app-specific initialization, you can do it here
[cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
int cacheSizeMemory = 8 * 1024 * 1024; // 8MB int cacheSizeDisk = 32 * 1024 * 1024; // 32MB
NSURLCache* sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"];
NSURLCache* sharedCache = [[[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"] autorelease];
[NSURLCache setSharedURLCache:sharedCache];
self = [super init]; return self; }
/**
self.window = [[UIWindow alloc] initWithFrame:screenBounds];
self.window = [[[UIWindow alloc] initWithFrame:screenBounds] autorelease];
self.window.autoresizesSubviews = YES;
self.viewController = [[MainViewController alloc] init];
self.viewController = [[[MainViewController alloc] init] autorelease];
// Set your app's start page by setting the <content src='foo.html' /> tag in config.xml.
// If necessary, uncomment the line below to override it.
// self.viewController.startPage = @"index.html";
// NOTE: To customize the view's frame size (which defaults to full screen), override
// [self.viewController viewWillAppear:] in your view controller.
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
// this happens while we are running ( in the background, or from within our own app ) // only valid if BucmiApp-Info.plist specifies a protocol to handle
(BOOL)application:(UIApplication)application openURL:(NSURL)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation { if (!url) { return NO; }
[self.viewController processOpenUrl:url];
// all plugins will get the notification, and their handlers will be called [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
return YES; }
// repost all remote and local notification using the default NSNotificationCenter so multiple plugins may respond
(void) application:(UIApplication)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData)deviceToken { // re-post ( broadcast ) NSString* token = [[[[deviceToken description] stringByReplacingOccurrencesOfString:@"<" withString:@""] stringByReplacingOccurrencesOfString:@">" withString:@""] stringByReplacingOccurrencesOfString:@" " withString:@""];
[[NSNotificationCenter defaultCenter] postNotificationName:CDVRemoteNotification object:token]; }
(NSUInteger)application:(UIApplication)application supportedInterfaceOrientationsForWindow:(UIWindow)window { // iPhone doesn't support upside down by default, while the iPad does. Override to allow all orientations always, and let the root view controller decide what's allowed (the supported orientations mask gets intersected). NSUInteger supportedInterfaceOrientations = (1 << UIInterfaceOrientationPortrait) | (1 << UIInterfaceOrientationLandscapeLeft) | (1 << UIInterfaceOrientationLandscapeRight) | (1 << UIInterfaceOrientationPortraitUpsideDown);
return supportedInterfaceOrientations; }
-(BOOL) openURL:(NSURL *) url { [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]]; [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPageDidLoadNotification object:url]];
return YES;
}
@end
thanks a lot!
Looks good to me friend. also i don't know how ur handleOpenUrl is in javascript. but i wait for deviceReady and when the device is ready i do whatever is inside handleOpenUrl i tried setting in timeout for code inside my handleOpenUrl but that didn't work so i just wait until device is ready to do the execution of code inside handleOpenUrl
This may be a duplicate, see my comment there: https://github.com/EddyVerbruggen/Custom-URL-scheme/issues/93#issuecomment-173371038
Finally i got it working!!! thx a lot to all of you guys...
Before i close it. Do u mind posting which solution got it working for u?
yes, for sure...it was a mix of the previous comments... i had to make the sahotaran changes on appDelegate, had to manage js action after deviceReady and i ha to remove the duplicate line as Lorensr said...
thanks to all of you!
@sahotataran No luck here. Tried the same.
I am using Ionic with Cordova. My problem is with handleOpenUrl when there is Cold Start on iOS.
in my setup the MainViewController is wrapped inside NavigationViewController and my NavigationViewController is the rootViewController of the window.
This set up works fine with launchUrl when app is running in the background.
so i pass in the url and i can navigate to any page i want to inside the Ionic App based on the url passed.
But this set up doesn't work when the app start from the cold start. On cold start it just stops at the home page.
but if i change the window.rootViewController back to MainViewController - the handleOpenUrl works fine - with cold start as well as from background.
Can i do anything to make it working in both the cases with my set up with NavigationViewController and the MainController being the part of the NavigationController ?