Question

I am working on an app that is based on ChattAr-iOS project from QuickBlox in which they have a UIWebViewController due to which I can't communicate with another app, everytime I try to open Waze app form my app using following code:

 - (void) navigateToLatitude:(double)latitude
              longitude:(double)longitude
{
  if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"waze://"]]) {
    //Waze is installed. Launch Waze and start navigation
    NSString *urlStr = [NSString stringWithFormat:@"waze://?ll=%f,%f&navigate=yes", latitude, longitude];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlStr]];
} else {
    //Waze is not installed. Launch AppStore to install Waze app
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunes.apple.com/us/app/id323229106"]];
    }
}

it navigates to that UIWebView. There is a class ChatARApplication in that project maybe that is causing the problem.

ChattARApplication.h

#import <UIKit/UIKit.h>

@interface ChattARApplication : UIApplication

@end

ChattARApplication.m

#import "ChattARApplication.h"
#import "WebViewController.h"
#import "AppDelegate.h"

@implementation ChattARApplication

 -(BOOL)openURL:(NSURL *)url{
    UITabBarController *tabBarControlelr = ((AppDelegate *)self.delegate).tabBarController;
if(tabBarControlelr.selectedIndex != 1){
    return [super openURL:url];
    }

    // handle chat messages' links
    WebViewController *webViewControleler = [[WebViewController alloc] init];
    webViewControleler.urlAdress = [url absoluteString];
    webViewControleler.webView.scalesPageToFit = YES;
    UINavigationController *chatViewController = [tabBarControlelr.viewControllers objectAtIndex:1];
    [chatViewController pushViewController:webViewControleler animated:YES];
    [webViewControleler autorelease];

    return NO;
}

@end
Was it helpful?

Solution

Solved the problem

This little peace of code did the trick

 if ([[url scheme] isEqualToString:@"waze"]) {
    return [super openURL:url];
}

In -(BOOL)openURL:(NSURL *)url

OTHER TIPS

main.m

int main(int argc, char *argv[]){
    @autoreleasepool {
        return UIApplicationMain(argc, argv, NSStringFromClass([ChattARApplication class]), NSStringFromClass([AppDelegate class]));
    }
}

I think it's the problem.If you want to keep the application setting, you may put some code in the -(BOOL)openURL:(NSURL *)url;

Hopes it can help you~~

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top