user1236971
user1236971

Reputation: 197

iOS handleOpenURL with Phonegap 1.6.0

Cordova: 1.6.0

iOS: 5.1

XCode: 4.3.1

I'm trying to tap into the handleOpenURL in Phonegap 1.6.0 with a very basic example program. I'd like to analyze a url every time a http/https request is made. All I have done right now is add a log message to see the host of the url.

- (BOOL) application:(UIApplication*)application handleOpenURL: 
(NSURL*)url 
{ 
    NSLog(@"Hi"); 
    NSLog(@"Host: %@", [url host]);

    if (!url) { 
        return NO; 
    }

    ... 
} 

However, the log message never writes anything to the console.

I did notice the comment:

// only valid if Example-Info.plist specifies a protocol to handle 

Perhaps my Example-Info.plist file is wrong? I've added the CFBundleURLTypes to it, assuming that's what it means by "specify a protocol to handle". Do I have to add something else somewhere? Below is the example section of my Example-Info.plist file. Is it possible the simulator is not recognizing my .plist modifications?

... 
<key>CFBundleURLTypes</key> 
<array> 
    <dict> 
        <key>CFBundleURLSchemes</key> 
            <array> 
                <string>http</string>
                <string>https</string> 
            </array> 
    </dict> 
</array>

I've also implmeneted, since handleOpenURL is deprecated.

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication (NSString *)sourceApplication annotation:(id)annotation
{
    NSLog(@"Hi");
    ...
}

Neither are getting called as I open URLs in my application. I've tried all the solutions in stack-overflow, with no such luck. If it is any help, I'm using jQuery mobile 1.1.0 for page transitions.

Upvotes: 1

Views: 1315

Answers (1)

koregan
koregan

Reputation: 10164

That is not the purpose of those methods. They are to deal with the URLs used to open your app not any URLs you open in a UIWebView.

You should be looking at the delegate methods for UIWebView

Specifically

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType

Upvotes: 1

Related Questions