How to open the pre installed app from the another hybrid application using worklight and ionic framework

丶灬走出姿态 提交于 2019-12-24 14:36:13

问题


I have a requirement to open the waze application which should be installed in mobile device when the another hybrid app's button click event is fired. I don't have any idea on this.

For this requirement i have to use worklight 6.3 & ionic framework.

Any help is appreciated.


回答1:


Your requirement has got nothing to do with Ionic.
You also did not mention if this is for Android or iOS.

Anyway, you can look at the following "regular" Hybrid project: https://www.dropbox.com/s/6fgtjhzgvl6p9n0/OpenExternalApplication.zip?dl=0

It contains the needed native code to open an existing (already installed) app (Waze) in iOS.

Part of the code:

- (void)openApp:(CDVInvokedUrlCommand*)command {

        NSString *wazeAppURL = @"waze://";
        NSString *mapsAppURL = @"maps://";

        BOOL canOpenURL = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:wazeAppURL]];

        NSString *url = canOpenURL ? wazeAppURL : mapsAppURL;
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];

        NSString *responseString =
        [NSString stringWithFormat:@"OK"];

        CDVPluginResult *pluginResult =
        [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:responseString];

        [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
    }


来源:https://stackoverflow.com/questions/33719344/how-to-open-the-pre-installed-app-from-the-another-hybrid-application-using-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!