From bb3327beeb86daba4c987edf2ae7198359cfaf0a Mon Sep 17 00:00:00 2001 From: Vivek Tiwari Date: Tue, 30 Jun 2015 15:46:07 +0530 Subject: [PATCH] Provide method to open native ios app settings --- src/ios/PushPlugin.m | 8 ++++++++ www/PushNotification.js | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/ios/PushPlugin.m b/src/ios/PushPlugin.m index 508110b..79174db 100644 --- a/src/ios/PushPlugin.m +++ b/src/ios/PushPlugin.m @@ -156,6 +156,14 @@ - (void)isEnabled:(CDVInvokedUrlCommand*)command { [self successWithMessage:jsStatement]; } +- (void)openSettings:(CDVInvokedUrlCommand*)command { + BOOL canOpenSettings = (&UIApplicationOpenSettingsURLString != NULL); + if (canOpenSettings) { + NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; + [[UIApplication sharedApplication] openURL:url]; + } +} + - (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { diff --git a/www/PushNotification.js b/www/PushNotification.js index 26e2d3c..40cfadd 100644 --- a/www/PushNotification.js +++ b/www/PushNotification.js @@ -113,6 +113,22 @@ PushNotification.prototype.isEnabled = function(successCallback, errorCallback){ cordova.exec(successCallback, errorCallback, "PushPlugin", "isEnabled", []); }; + +//To open ios app settings +PushNotification.prototype.openSettings = function(successCallback, errorCallback){ + if (errorCallback == null) { errorCallback = function() {}} + + if (typeof errorCallback != "function") { + console.log("PushNotification.openSettings failure: failure parameter not a function"); + return + } + if (typeof successCallback != "function") { + console.log("PushNotification.openSettings failure: success callback parameter must be a function"); + return + } + cordova.exec(successCallback, errorCallback, "PushPlugin", "openSettings", []); +}; + //------------------------------------------------------------------- if(!window.plugins) {