Skip to content

Commit

Permalink
Merge pull request #11 from hashcube/ios-is-installed
Browse files Browse the repository at this point in the history
Ios isInstalled added
  • Loading branch information
bijoshtj authored Apr 26, 2017
2 parents dfd3c56 + 18eda98 commit bcfaada
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
4 changes: 3 additions & 1 deletion android/UtilsPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,9 @@ public void isAppInstalled(String params) {
PackageManager pm = _context.getPackageManager();
try {
JSONObject data = new JSONObject(params);
pm.getPackageInfo(data.optString("packageName", ""), PackageManager.GET_ACTIVITIES);
String packageName = data.optString("identifier", "");

pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
available = true;
} catch (PackageManager.NameNotFoundException e) {
logger.log("{utils-native} app not available for package");
Expand Down
8 changes: 8 additions & 0 deletions ios/UtilsPlugin.mm
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ - (UIApplicationShortcutIconType) UIApplicationShortcutIconTypeFromString:(NSStr
}
}

- (void)isAppInstalled: (NSDictionary *)jsonObject {
NSString *scheme = [NSString stringWithFormat:@"%@%@", [jsonObject objectForKey:@"identifier"], @"://"];

[[PluginManager get] dispatchJSEvent:[NSDictionary dictionaryWithObjectsAndKeys:
@"AppFound",@"name",
@([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString: scheme]]), @"found",
nil]];
}

- (void)getDeviceInfo:(NSDictionary *)jsonObject {
NSString *m_platform = 0;
Expand Down
6 changes: 3 additions & 3 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ exports = new (Class(function () {
pluginSend('getInstalledApps');
};

this.isAppInstalled = function (packageName, cb) {
log("is app installed: " + packageName);
this.isAppInstalled = function (identifier, cb) {
log("is app installed: " + identifier);
cb_app_found = cb;
pluginSend('isAppInstalled', {
packageName: packageName
identifier: identifier
});
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "utils",
"version": "3.4.5",
"version": "3.4.6",
"devkit": {
"clientPaths": {
"utils": "js"
Expand Down

0 comments on commit bcfaada

Please sign in to comment.