summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/ios/Stone Island/Plugins
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/platforms/ios/Stone Island/Plugins')
-rwxr-xr-xStoneIsland/platforms/ios/Stone Island/Plugins/com.ionic.keyboard/UIWebViewExtension.h4
-rwxr-xr-xStoneIsland/platforms/ios/Stone Island/Plugins/com.ionic.keyboard/UIWebViewExtension.m109
-rw-r--r--[-rwxr-xr-x]StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-console/CDVLogger.h0
-rw-r--r--[-rwxr-xr-x]StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-console/CDVLogger.m0
-rw-r--r--[-rwxr-xr-x]StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-device/CDVDevice.h0
-rw-r--r--[-rwxr-xr-x]StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-device/CDVDevice.m51
-rw-r--r--[-rwxr-xr-x]StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-dialogs/CDVNotification.h0
-rw-r--r--[-rwxr-xr-x]StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-dialogs/CDVNotification.m95
-rw-r--r--[-rwxr-xr-x]StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-geolocation/CDVLocation.h0
-rw-r--r--[-rwxr-xr-x]StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-geolocation/CDVLocation.m65
-rw-r--r--[-rwxr-xr-x]StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-inappbrowser/CDVInAppBrowser.h1
-rw-r--r--[-rwxr-xr-x]StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-inappbrowser/CDVInAppBrowser.m86
-rw-r--r--[-rwxr-xr-x]StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-network-information/CDVConnection.h0
-rw-r--r--[-rwxr-xr-x]StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-network-information/CDVConnection.m31
-rw-r--r--[-rwxr-xr-x]StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-network-information/CDVReachability.h0
-rw-r--r--[-rwxr-xr-x]StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-network-information/CDVReachability.m6
-rw-r--r--StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-splashscreen/CDVSplashScreen.h2
-rw-r--r--StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-splashscreen/CDVSplashScreen.m181
-rw-r--r--StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-splashscreen/CDVViewController+SplashScreen.m7
-rw-r--r--StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-x-socialsharing/NSString+URLEncoding.h5
-rw-r--r--StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-x-socialsharing/NSString+URLEncoding.m30
-rw-r--r--[-rwxr-xr-x]StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-x-socialsharing/SocialSharing.h3
-rw-r--r--[-rwxr-xr-x]StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-x-socialsharing/SocialSharing.m157
-rw-r--r--[-rwxr-xr-x]StoneIsland/platforms/ios/Stone Island/Plugins/ionic-plugin-keyboard/IonicKeyboard.h (renamed from StoneIsland/platforms/ios/Stone Island/Plugins/com.ionic.keyboard/IonicKeyboard.h)3
-rw-r--r--[-rwxr-xr-x]StoneIsland/platforms/ios/Stone Island/Plugins/ionic-plugin-keyboard/IonicKeyboard.m (renamed from StoneIsland/platforms/ios/Stone Island/Plugins/com.ionic.keyboard/IonicKeyboard.m)54
-rwxr-xr-xStoneIsland/platforms/ios/Stone Island/Plugins/phonegap-plugin-push/AppDelegate+notification.h21
-rwxr-xr-xStoneIsland/platforms/ios/Stone Island/Plugins/phonegap-plugin-push/AppDelegate+notification.m167
-rwxr-xr-xStoneIsland/platforms/ios/Stone Island/Plugins/phonegap-plugin-push/PushPlugin.h62
-rwxr-xr-xStoneIsland/platforms/ios/Stone Island/Plugins/phonegap-plugin-push/PushPlugin.m347
29 files changed, 564 insertions, 923 deletions
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/com.ionic.keyboard/UIWebViewExtension.h b/StoneIsland/platforms/ios/Stone Island/Plugins/com.ionic.keyboard/UIWebViewExtension.h
deleted file mode 100755
index 1d6c293d..00000000
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/com.ionic.keyboard/UIWebViewExtension.h
+++ /dev/null
@@ -1,4 +0,0 @@
-@interface UIWebView (HackishAccessoryHiding)
-@property (nonatomic, assign) BOOL hackishlyHidesInputAccessoryView;
-//@property (nonatomic, assign) BOOL styleDark;
-@end
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/com.ionic.keyboard/UIWebViewExtension.m b/StoneIsland/platforms/ios/Stone Island/Plugins/com.ionic.keyboard/UIWebViewExtension.m
deleted file mode 100755
index 25403e6f..00000000
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/com.ionic.keyboard/UIWebViewExtension.m
+++ /dev/null
@@ -1,109 +0,0 @@
-#import <objc/runtime.h>
-#import <UIKit/UIKit.h>
-#import "UIWebViewExtension.h"
-
-//Credit: https://gist.github.com/bjhomer/2048571
-//Also: http://stackoverflow.com/a/23398487/1091751
-@implementation UIWebView (HackishAccessoryHiding)
-
-static const char * const hackishFixClassName = "UIWebBrowserViewMinusAccessoryView";
-static Class hackishFixClass = Nil;
-
-- (UIView *)hackishlyFoundBrowserView {
- UIScrollView *scrollView = self.scrollView;
-
- UIView *browserView = nil;
- for (UIView *subview in scrollView.subviews) {
- if ([NSStringFromClass([subview class]) hasPrefix:@"UIWebBrowserView"]) {
- browserView = subview;
- break;
- }
- }
- return browserView;
-}
-
-- (id)methodReturningNil {
- return nil;
-}
-
-- (void)ensureHackishSubclassExistsOfBrowserViewClass:(Class)browserViewClass {
- if (!hackishFixClass) {
- Class newClass = objc_allocateClassPair(browserViewClass, hackishFixClassName, 0);
- IMP nilImp = [self methodForSelector:@selector(methodReturningNil)];
- class_addMethod(newClass, @selector(inputAccessoryView), nilImp, "@@:");
- objc_registerClassPair(newClass);
-
- hackishFixClass = newClass;
- }
-}
-
-- (BOOL) hackishlyHidesInputAccessoryView {
- UIView *browserView = [self hackishlyFoundBrowserView];
- return [browserView class] == hackishFixClass;
-}
-
-- (void) setHackishlyHidesInputAccessoryView:(BOOL)value {
- UIView *browserView = [self hackishlyFoundBrowserView];
- if (browserView == nil) {
- return;
- }
- [self ensureHackishSubclassExistsOfBrowserViewClass:[browserView class]];
-
- if (value) {
- object_setClass(browserView, hackishFixClass);
- }
- else {
- Class normalClass = objc_getClass("UIWebBrowserView");
- object_setClass(browserView, normalClass);
- }
- [browserView reloadInputViews];
-}
-/* ---------------------------------------------------------------- */
-
-/*
-- (UIKeyboardAppearance) darkKeyboardAppearanceTemplateMethod {
- return UIKeyboardAppearanceDark;
-}
-
-- (UIKeyboardAppearance) lightKeyboardAppearanceTemplateMethod {
- return UIKeyboardAppearanceLight;
-}
-
-- (BOOL) styleDark {
- UIView *browserView = [self hackishlyFoundBrowserView];
- if (browserView == nil) {
- return false;
- }
-
- Method m = class_getInstanceMethod( [self class], @selector( darkKeyboardAppearanceTemplateMethod ) );
- IMP imp = method_getImplementation( m );
-
- Method m2 = class_getInstanceMethod( [browserView class], @selector(keyboardAppearance) );
- IMP imp2 = method_getImplementation( m2 );
-
- return imp == imp2;
-}
-
-- (void) setStyleDark:(BOOL)styleDark {
- UIView *browserView = [self hackishlyFoundBrowserView];
- if (browserView == nil) {
- return;
- }
-
- if ( styleDark ) {
- Method m = class_getInstanceMethod( [self class], @selector( darkKeyboardAppearanceTemplateMethod ) );
- IMP imp = method_getImplementation( m );
- const char* typeEncoding = method_getTypeEncoding( m );
- class_replaceMethod( [browserView class], @selector(keyboardAppearance), imp, typeEncoding );
- }
- else {
- Method m = class_getInstanceMethod( [self class], @selector( lightKeyboardAppearanceTemplateMethod ) );
- IMP imp = method_getImplementation( m );
- const char* typeEncoding = method_getTypeEncoding( m );
- class_replaceMethod( [browserView class], @selector(keyboardAppearance), imp, typeEncoding );
- }
-}
-*/
-
-@end
-
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-console/CDVLogger.h b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-console/CDVLogger.h
index 7cfb3063..7cfb3063 100755..100644
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-console/CDVLogger.h
+++ b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-console/CDVLogger.h
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-console/CDVLogger.m b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-console/CDVLogger.m
index ccfa3a51..ccfa3a51 100755..100644
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-console/CDVLogger.m
+++ b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-console/CDVLogger.m
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-device/CDVDevice.h b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-device/CDVDevice.h
index a146d882..a146d882 100755..100644
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-device/CDVDevice.h
+++ b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-device/CDVDevice.h
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-device/CDVDevice.m b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-device/CDVDevice.m
index 5a3f4708..4d75a574 100755..100644
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-device/CDVDevice.m
+++ b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-device/CDVDevice.m
@@ -19,6 +19,7 @@
#include <sys/types.h>
#include <sys/sysctl.h>
+#include "TargetConditionals.h"
#import <Cordova/CDV.h>
#import "CDVDevice.h"
@@ -49,21 +50,23 @@
{
NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
static NSString* UUID_KEY = @"CDVUUID";
-
+
+ // Check user defaults first to maintain backwards compaitibility with previous versions
+ // which didn't user identifierForVendor
NSString* app_uuid = [userDefaults stringForKey:UUID_KEY];
-
if (app_uuid == nil) {
- CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
- CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuidRef);
+ if ([device respondsToSelector:@selector(identifierForVendor)]) {
+ app_uuid = [[device identifierForVendor] UUIDString];
+ } else {
+ CFUUIDRef uuid = CFUUIDCreate(NULL);
+ app_uuid = (__bridge_transfer NSString *)CFUUIDCreateString(NULL, uuid);
+ CFRelease(uuid);
+ }
- app_uuid = [NSString stringWithString:(__bridge NSString*)uuidString];
[userDefaults setObject:app_uuid forKey:UUID_KEY];
[userDefaults synchronize];
-
- CFRelease(uuidString);
- CFRelease(uuidRef);
}
-
+
return app_uuid;
}
@@ -78,17 +81,16 @@
- (NSDictionary*)deviceProperties
{
UIDevice* device = [UIDevice currentDevice];
- NSMutableDictionary* devProps = [NSMutableDictionary dictionaryWithCapacity:4];
- [devProps setObject:@"Apple" forKey:@"manufacturer"];
- [devProps setObject:[device modelVersion] forKey:@"model"];
- [devProps setObject:@"iOS" forKey:@"platform"];
- [devProps setObject:[device systemVersion] forKey:@"version"];
- [devProps setObject:[self uniqueAppInstanceIdentifier:device] forKey:@"uuid"];
- [devProps setObject:[[self class] cordovaVersion] forKey:@"cordova"];
-
- NSDictionary* devReturn = [NSDictionary dictionaryWithDictionary:devProps];
- return devReturn;
+ return @{
+ @"manufacturer": @"Apple",
+ @"model": [device modelVersion],
+ @"platform": @"iOS",
+ @"version": [device systemVersion],
+ @"uuid": [self uniqueAppInstanceIdentifier:device],
+ @"cordova": [[self class] cordovaVersion],
+ @"isVirtual": @([self isVirtual])
+ };
}
+ (NSString*)cordovaVersion
@@ -96,4 +98,15 @@
return CDV_VERSION;
}
+- (BOOL)isVirtual
+{
+ #if TARGET_OS_SIMULATOR
+ return true;
+ #elif TARGET_IPHONE_SIMULATOR
+ return true;
+ #else
+ return false;
+ #endif
+}
+
@end
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-dialogs/CDVNotification.h b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-dialogs/CDVNotification.h
index 9253f6a9..9253f6a9 100755..100644
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-dialogs/CDVNotification.h
+++ b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-dialogs/CDVNotification.h
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-dialogs/CDVNotification.m b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-dialogs/CDVNotification.m
index 1581ad3c..0dd3d2cb 100755..100644
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-dialogs/CDVNotification.m
+++ b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-dialogs/CDVNotification.m
@@ -23,6 +23,7 @@
#define DIALOG_TYPE_PROMPT @"prompt"
static void soundCompletionCallback(SystemSoundID ssid, void* data);
+static NSMutableArray *alertList = nil;
@implementation CDVNotification
@@ -39,7 +40,7 @@ static void soundCompletionCallback(SystemSoundID ssid, void* data);
- (void)showDialogWithMessage:(NSString*)message title:(NSString*)title buttons:(NSArray*)buttons defaultText:(NSString*)defaultText callbackId:(NSString*)callbackId dialogType:(NSString*)dialogType
{
- NSUInteger count = [buttons count];
+ int count = (int)[buttons count];
#ifdef __IPHONE_8_0
if (NSClassFromString(@"UIAlertController")) {
@@ -58,33 +59,32 @@ static void soundCompletionCallback(SystemSoundID ssid, void* data);
alertController.view.frame = alertFrame;
}
-
+
+ __weak CDVNotification* weakNotif = self;
+
for (int n = 0; n < count; n++) {
-
- UIAlertAction* action = [UIAlertAction actionWithTitle:[buttons objectAtIndex:n] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action)
- {
- CDVPluginResult* result;
-
- if ([dialogType isEqualToString:DIALOG_TYPE_PROMPT]) {
-
- NSString* value0 = [[alertController.textFields objectAtIndex:0] text];
- NSDictionary* info = @{
- @"buttonIndex":@(n + 1),
- @"input1":(value0 ? value0 : [NSNull null])
- };
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:info];
-
- } else {
-
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:(int)(n + 1)];
-
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
-
- }];
- [alertController addAction:action];
-
+ [alertController addAction:[UIAlertAction actionWithTitle:[buttons objectAtIndex:n]
+ style:UIAlertActionStyleDefault
+ handler:^(UIAlertAction * action)
+ {
+ CDVPluginResult* result;
+
+ if ([dialogType isEqualToString:DIALOG_TYPE_PROMPT])
+ {
+ NSString* value0 = [[alertController.textFields objectAtIndex:0] text];
+ NSDictionary* info = @{
+ @"buttonIndex":@(n + 1),
+ @"input1":(value0 ? value0 : [NSNull null])
+ };
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:info];
+ }
+ else
+ {
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:(int)(n + 1)];
+ }
+
+ [weakNotif.commandDelegate sendPluginResult:result callbackId:callbackId];
+ }]];
}
if ([dialogType isEqualToString:DIALOG_TYPE_PROMPT]) {
@@ -94,12 +94,19 @@ static void soundCompletionCallback(SystemSoundID ssid, void* data);
}];
}
+ if(!alertList)
+ alertList = [[NSMutableArray alloc] init];
+ [alertList addObject:alertController];
+ if ([alertList count]==1) {
+ [self presentAlertcontroller];
+ }
- [self.viewController presentViewController:alertController animated:YES completion:nil];
-
- } else {
+ }
+ else
+ {
#endif
+
CDVAlertView* alertView = [[CDVAlertView alloc]
initWithTitle:title
message:message
@@ -183,6 +190,14 @@ static void soundCompletionCallback(SystemSoundID ssid, void* data);
[self.commandDelegate sendPluginResult:result callbackId:cdvAlertView.callbackId];
}
+- (void)didPresentAlertView:(UIAlertView*)alertView
+{
+ //show keyboard on iOS 8
+ if (alertView.alertViewStyle == UIAlertViewStylePlainTextInput){
+ [[alertView textFieldAtIndex:0] selectAll:nil];
+ }
+}
+
static void playBeep(int count) {
SystemSoundID completeSound;
NSInteger cbDataCount = count;
@@ -211,6 +226,26 @@ static void soundCompletionCallback(SystemSoundID ssid, void* data) {
playBeep([count intValue]);
}
+-(UIViewController *)getTopPresentedViewController {
+ UIViewController *presentingViewController = self.viewController;
+ while(presentingViewController.presentedViewController != nil && ![presentingViewController.presentedViewController isBeingDismissed])
+ {
+ presentingViewController = presentingViewController.presentedViewController;
+ }
+ return presentingViewController;
+}
+
+-(void)presentAlertcontroller {
+
+ __weak CDVNotification* weakNotif = self;
+ [self.getTopPresentedViewController presentViewController:[alertList firstObject] animated:YES completion:^{
+ [alertList removeObject:[alertList firstObject]];
+ if ([alertList count]>0) {
+ [weakNotif presentAlertcontroller];
+ }
+ }];
+
+}
@end
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-geolocation/CDVLocation.h b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-geolocation/CDVLocation.h
index cce2738f..cce2738f 100755..100644
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-geolocation/CDVLocation.h
+++ b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-geolocation/CDVLocation.h
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-geolocation/CDVLocation.m b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-geolocation/CDVLocation.m
index 8b543c8e..e4b34a11 100755..100644
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-geolocation/CDVLocation.m
+++ b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-geolocation/CDVLocation.m
@@ -122,17 +122,17 @@
NSUInteger code = [CLLocationManager authorizationStatus];
if (code == kCLAuthorizationStatusNotDetermined && ([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)] || [self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])) { //iOS8+
__highAccuracyEnabled = enableHighAccuracy;
- if([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"]){
- [self.locationManager requestAlwaysAuthorization];
- } else if([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"]) {
- [self.locationManager requestWhenInUseAuthorization];
+ if([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"]){
+ [self.locationManager requestWhenInUseAuthorization];
+ } else if([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"]) {
+ [self.locationManager requestAlwaysAuthorization];
} else {
NSLog(@"[Warning] No NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription key is defined in the Info.plist file.");
}
return;
}
#endif
-
+
// Tell the location manager to start notifying us of location updates. We
// first stop, and then start the updating to ensure we get at least one
// update, even if our location did not change.
@@ -148,9 +148,8 @@
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
} else {
__highAccuracyEnabled = NO;
- // TODO: Set distance filter to 10 meters? and desired accuracy to nearest ten meters? arbitrary.
self.locationManager.distanceFilter = 10;
- self.locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
+ self.locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
}
}
@@ -193,35 +192,37 @@
- (void)getLocation:(CDVInvokedUrlCommand*)command
{
- NSString* callbackId = command.callbackId;
- BOOL enableHighAccuracy = [[command argumentAtIndex:0] boolValue];
+ [self.commandDelegate runInBackground:^{
+ NSString* callbackId = command.callbackId;
+ BOOL enableHighAccuracy = [[command argumentAtIndex:0] boolValue];
- if ([self isLocationServicesEnabled] == NO) {
- NSMutableDictionary* posError = [NSMutableDictionary dictionaryWithCapacity:2];
- [posError setObject:[NSNumber numberWithInt:PERMISSIONDENIED] forKey:@"code"];
- [posError setObject:@"Location services are disabled." forKey:@"message"];
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:posError];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- } else {
- if (!self.locationData) {
- self.locationData = [[CDVLocationData alloc] init];
- }
- CDVLocationData* lData = self.locationData;
- if (!lData.locationCallbacks) {
- lData.locationCallbacks = [NSMutableArray arrayWithCapacity:1];
- }
+ if ([self isLocationServicesEnabled] == NO) {
+ NSMutableDictionary* posError = [NSMutableDictionary dictionaryWithCapacity:2];
+ [posError setObject:[NSNumber numberWithInt:PERMISSIONDENIED] forKey:@"code"];
+ [posError setObject:@"Location services are disabled." forKey:@"message"];
+ CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:posError];
+ [self.commandDelegate sendPluginResult:result callbackId:callbackId];
+ } else {
+ if (!self.locationData) {
+ self.locationData = [[CDVLocationData alloc] init];
+ }
+ CDVLocationData* lData = self.locationData;
+ if (!lData.locationCallbacks) {
+ lData.locationCallbacks = [NSMutableArray arrayWithCapacity:1];
+ }
- if (!__locationStarted || (__highAccuracyEnabled != enableHighAccuracy)) {
- // add the callbackId into the array so we can call back when get data
- if (callbackId != nil) {
- [lData.locationCallbacks addObject:callbackId];
+ if (!__locationStarted || (__highAccuracyEnabled != enableHighAccuracy)) {
+ // add the callbackId into the array so we can call back when get data
+ if (callbackId != nil) {
+ [lData.locationCallbacks addObject:callbackId];
+ }
+ // Tell the location manager to start notifying us of heading updates
+ [self startLocation:enableHighAccuracy];
+ } else {
+ [self returnLocationInfo:callbackId andKeepCallback:NO];
}
- // Tell the location manager to start notifying us of heading updates
- [self startLocation:enableHighAccuracy];
- } else {
- [self returnLocationInfo:callbackId andKeepCallback:NO];
}
- }
+ }];
}
- (void)addWatch:(CDVInvokedUrlCommand*)command
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-inappbrowser/CDVInAppBrowser.h b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-inappbrowser/CDVInAppBrowser.h
index 1ccc7b14..6bb0ec16 100755..100644
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-inappbrowser/CDVInAppBrowser.h
+++ b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-inappbrowser/CDVInAppBrowser.h
@@ -30,7 +30,6 @@
@class CDVInAppBrowserViewController;
@interface CDVInAppBrowser : CDVPlugin {
- BOOL _injectedIframeBridge;
}
@property (nonatomic, retain) CDVInAppBrowserViewController* inAppBrowserViewController;
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-inappbrowser/CDVInAppBrowser.m b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-inappbrowser/CDVInAppBrowser.m
index 47a8ab3a..b342ca73 100755..100644
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-inappbrowser/CDVInAppBrowser.m
+++ b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-inappbrowser/CDVInAppBrowser.m
@@ -47,6 +47,11 @@
_callbackIdPattern = nil;
}
+- (id)settingForKey:(NSString*)key
+{
+ return [self.commandDelegate.settings objectForKey:[key lowercaseString]];
+}
+
- (void)onReset
{
[self close:nil];
@@ -137,8 +142,16 @@
}
if (self.inAppBrowserViewController == nil) {
- NSString* originalUA = [CDVUserAgentUtil originalUserAgent];
- self.inAppBrowserViewController = [[CDVInAppBrowserViewController alloc] initWithUserAgent:originalUA prevUserAgent:[self.commandDelegate userAgent] browserOptions: browserOptions];
+ NSString* userAgent = [CDVUserAgentUtil originalUserAgent];
+ NSString* overrideUserAgent = [self settingForKey:@"OverrideUserAgent"];
+ NSString* appendUserAgent = [self settingForKey:@"AppendUserAgent"];
+ if(overrideUserAgent){
+ userAgent = overrideUserAgent;
+ }
+ if(appendUserAgent){
+ userAgent = [userAgent stringByAppendingString: appendUserAgent];
+ }
+ self.inAppBrowserViewController = [[CDVInAppBrowserViewController alloc] initWithUserAgent:userAgent prevUserAgent:[self.commandDelegate userAgent] browserOptions: browserOptions];
self.inAppBrowserViewController.navigationDelegate = self;
if ([self.viewController conformsToProtocol:@protocol(CDVScreenOrientationDelegate)]) {
@@ -218,6 +231,7 @@
initWithRootViewController:self.inAppBrowserViewController];
nav.orientationDelegate = self.inAppBrowserViewController;
nav.navigationBarHidden = YES;
+ nav.modalPresentationStyle = self.inAppBrowserViewController.modalPresentationStyle;
__weak CDVInAppBrowser* weakSelf = self;
@@ -231,25 +245,25 @@
- (void)openInCordovaWebView:(NSURL*)url withOptions:(NSString*)options
{
- if ([self.commandDelegate URLIsWhitelisted:url]) {
- NSURLRequest* request = [NSURLRequest requestWithURL:url];
+ NSURLRequest* request = [NSURLRequest requestWithURL:url];
+
#ifdef __CORDOVA_4_0_0
- [self.webViewEngine loadRequest:request];
+ // the webview engine itself will filter for this according to <allow-navigation> policy
+ // in config.xml for cordova-ios-4.0
+ [self.webViewEngine loadRequest:request];
#else
+ if ([self.commandDelegate URLIsWhitelisted:url]) {
[self.webView loadRequest:request];
-#endif
} else { // this assumes the InAppBrowser can be excepted from the white-list
[self openInInAppBrowser:url withOptions:options];
}
+#endif
}
- (void)openInSystem:(NSURL*)url
{
- if ([[UIApplication sharedApplication] canOpenURL:url]) {
- [[UIApplication sharedApplication] openURL:url];
- } else { // handle any custom schemes to plugins
- [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
- }
+ [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
+ [[UIApplication sharedApplication] openURL:url];
}
// This is a helper method for the inject{Script|Style}{Code|File} API calls, which
@@ -263,11 +277,8 @@
- (void)injectDeferredObject:(NSString*)source withWrapper:(NSString*)jsWrapper
{
- if (!_injectedIframeBridge) {
- _injectedIframeBridge = YES;
- // Create an iframe bridge in the new document to communicate with the CDVInAppBrowserViewController
- [self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:@"(function(d){var e = _cdvIframeBridge = d.createElement('iframe');e.style.display='none';d.body.appendChild(e);})(document)"];
- }
+ // Ensure an iframe bridge is created to communicate with the CDVInAppBrowserViewController
+ [self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:@"(function(d){_cdvIframeBridge=d.getElementById('_cdvIframeBridge');if(!_cdvIframeBridge) {var e = _cdvIframeBridge = d.createElement('iframe');e.id='_cdvIframeBridge'; e.style.display='none';d.body.appendChild(e);}})(document)"];
if (jsWrapper != nil) {
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:@[source] options:0 error:nil];
@@ -390,7 +401,14 @@
[self.commandDelegate sendPluginResult:pluginResult callbackId:scriptCallbackId];
return NO;
}
- } else if ((self.callbackId != nil) && isTopLevelNavigation) {
+ }
+ //if is an app store link, let the system handle it, otherwise it fails to load it
+ else if ([[ url scheme] isEqualToString:@"itms-appss"] || [[ url scheme] isEqualToString:@"itms-apps"]) {
+ [theWebView stopLoading];
+ [self openInSystem:url];
+ return NO;
+ }
+ else if ((self.callbackId != nil) && isTopLevelNavigation) {
// Send a loadstart event for each top-level navigation (includes redirects).
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
messageAsDictionary:@{@"type":@"loadstart", @"url":[url absoluteString]}];
@@ -404,7 +422,6 @@
- (void)webViewDidStartLoad:(UIWebView*)theWebView
{
- _injectedIframeBridge = NO;
}
- (void)webViewDidFinishLoad:(UIWebView*)theWebView
@@ -512,15 +529,15 @@
self.webView.scalesPageToFit = NO;
self.webView.userInteractionEnabled = YES;
- self.spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
+ self.spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
self.spinner.alpha = 1.000;
self.spinner.autoresizesSubviews = YES;
- self.spinner.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin;
+ self.spinner.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin);
self.spinner.clearsContextBeforeDrawing = NO;
self.spinner.clipsToBounds = NO;
self.spinner.contentMode = UIViewContentModeScaleToFill;
- self.spinner.frame = CGRectMake(454.0, 231.0, 20.0, 20.0);
- self.spinner.hidden = YES;
+ self.spinner.frame = CGRectMake(CGRectGetMidX(self.webView.frame), CGRectGetMidY(self.webView.frame), 20.0, 20.0);
+ self.spinner.hidden = NO;
self.spinner.hidesWhenStopped = YES;
self.spinner.multipleTouchEnabled = NO;
self.spinner.opaque = NO;
@@ -749,6 +766,10 @@
return UIStatusBarStyleDefault;
}
+- (BOOL)prefersStatusBarHidden {
+ return NO;
+}
+
- (void)close
{
[CDVUserAgentUtil releaseLock:&_userAgentLockToken];
@@ -988,19 +1009,38 @@
@implementation CDVInAppBrowserNavigationController : UINavigationController
+- (void) dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion {
+ if ( self.presentedViewController) {
+ [super dismissViewControllerAnimated:flag completion:completion];
+ }
+}
+
- (void) viewDidLoad {
CGRect frame = [UIApplication sharedApplication].statusBarFrame;
// simplified from: http://stackoverflow.com/a/25669695/219684
- UIToolbar* bgToolbar = [[UIToolbar alloc] initWithFrame:frame];
+ UIToolbar* bgToolbar = [[UIToolbar alloc] initWithFrame:[self invertFrameIfNeeded:frame]];
bgToolbar.barStyle = UIBarStyleDefault;
+ [bgToolbar setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[self.view addSubview:bgToolbar];
[super viewDidLoad];
}
+- (CGRect) invertFrameIfNeeded:(CGRect)rect {
+ // We need to invert since on iOS 7 frames are always in Portrait context
+ if (!IsAtLeastiOSVersion(@"8.0")) {
+ if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) {
+ CGFloat temp = rect.size.width;
+ rect.size.width = rect.size.height;
+ rect.size.height = temp;
+ }
+ rect.origin = CGPointZero;
+ }
+ return rect;
+}
#pragma mark CDVScreenOrientationDelegate
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-network-information/CDVConnection.h b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-network-information/CDVConnection.h
index 8add0279..8add0279 100755..100644
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-network-information/CDVConnection.h
+++ b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-network-information/CDVConnection.h
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-network-information/CDVConnection.m b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-network-information/CDVConnection.m
index 37497675..6715322a 100755..100644
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-network-information/CDVConnection.m
+++ b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-network-information/CDVConnection.m
@@ -16,6 +16,7 @@
specific language governing permissions and limitations
under the License.
*/
+#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#import "CDVConnection.h"
#import "CDVReachability.h"
@@ -57,6 +58,32 @@
if (isConnectionRequired) {
return @"none";
} else {
+ if ([[[UIDevice currentDevice] systemVersion] compare:@"7.0" options:NSNumericSearch] != NSOrderedAscending) {
+ CTTelephonyNetworkInfo *telephonyInfo = [CTTelephonyNetworkInfo new];
+ if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyGPRS]) {
+ return @"2g";
+ } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyEdge]) {
+ return @"2g";
+ } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyWCDMA]) {
+ return @"3g";
+ } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSDPA]) {
+ return @"3g";
+ } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSUPA]) {
+ return @"3g";
+ } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMA1x]) {
+ return @"3g";
+ } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORev0]) {
+ return @"3g";
+ } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevA]) {
+ return @"3g";
+ } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevB]) {
+ return @"3g";
+ } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyeHRPD]) {
+ return @"3g";
+ } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyLTE]) {
+ return @"4g";
+ }
+ }
return @"cellular";
}
}
@@ -118,7 +145,9 @@
[self.internetReach startNotifier];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateConnectionType:)
name:kReachabilityChangedNotification object:nil];
- if (&UIApplicationDidEnterBackgroundNotification && &UIApplicationWillEnterForegroundNotification) {
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateConnectionType:)
+ name:CTRadioAccessTechnologyDidChangeNotification object:nil];
+ if (UIApplicationDidEnterBackgroundNotification && UIApplicationWillEnterForegroundNotification) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onPause) name:UIApplicationDidEnterBackgroundNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResume) name:UIApplicationWillEnterForegroundNotification object:nil];
}
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-network-information/CDVReachability.h b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-network-information/CDVReachability.h
index 01a95c35..01a95c35 100755..100644
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-network-information/CDVReachability.h
+++ b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-network-information/CDVReachability.h
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-network-information/CDVReachability.m b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-network-information/CDVReachability.m
index c60261ae..1399867e 100755..100644
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-network-information/CDVReachability.m
+++ b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-network-information/CDVReachability.m
@@ -142,6 +142,9 @@ static void CDVReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkRe
retVal->reachabilityRef = reachability;
retVal->localWiFiRef = NO;
}
+ else {
+ CFRelease(reachability);
+ }
}
return retVal;
}
@@ -156,6 +159,9 @@ static void CDVReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkRe
retVal->reachabilityRef = reachability;
retVal->localWiFiRef = NO;
}
+ else {
+ CFRelease(reachability);
+ }
}
return retVal;
}
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-splashscreen/CDVSplashScreen.h b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-splashscreen/CDVSplashScreen.h
index 0d6ae397..ec5d6022 100644
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-splashscreen/CDVSplashScreen.h
+++ b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-splashscreen/CDVSplashScreen.h
@@ -23,6 +23,7 @@
typedef struct {
BOOL iPhone;
BOOL iPad;
+ BOOL iPhone4;
BOOL iPhone5;
BOOL iPhone6;
BOOL iPhone6Plus;
@@ -35,6 +36,7 @@ typedef struct {
UIImageView* _imageView;
NSString* _curImageName;
BOOL _visible;
+ BOOL _destroyed;
}
- (void)show:(CDVInvokedUrlCommand*)command;
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-splashscreen/CDVSplashScreen.m b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-splashscreen/CDVSplashScreen.m
index a1add304..8ad8116b 100644
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-splashscreen/CDVSplashScreen.m
+++ b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-splashscreen/CDVSplashScreen.m
@@ -23,6 +23,7 @@
#import "CDVViewController+SplashScreen.h"
#define kSplashScreenDurationDefault 3000.0f
+#define kFadeDurationDefault 500.0f
@implementation CDVSplashScreen
@@ -41,7 +42,7 @@
- (void)hide:(CDVInvokedUrlCommand*)command
{
- [self setVisible:NO];
+ [self setVisible:NO andForce:YES];
}
- (void)pageDidLoad
@@ -76,7 +77,7 @@
BOOL autorotateValue = (device.iPad || device.iPhone6Plus) ?
[(CDVViewController *)self.viewController shouldAutorotateDefaultValue] :
NO;
-
+
[(CDVViewController *)self.viewController setEnabledAutorotation:autorotateValue];
NSString* topActivityIndicator = [self.commandDelegate.settings objectForKey:[@"TopActivityIndicator" lowercaseString]];
@@ -120,6 +121,7 @@
[parentView addObserver:self forKeyPath:@"bounds" options:0 context:nil];
[self updateImage];
+ _destroyed = NO;
}
- (void)hideViews
@@ -130,6 +132,7 @@
- (void)destroyViews
{
+ _destroyed = YES;
[(CDVViewController *)self.viewController setEnabledAutorotation:[(CDVViewController *)self.viewController shouldAutorotateDefaultValue]];
[_imageView removeFromSuperview];
@@ -139,30 +142,39 @@
_curImageName = nil;
self.viewController.view.userInteractionEnabled = YES; // re-enable user interaction upon completion
- [self.viewController.view removeObserver:self forKeyPath:@"frame"];
- [self.viewController.view removeObserver:self forKeyPath:@"bounds"];
+ @try {
+ [self.viewController.view removeObserver:self forKeyPath:@"frame"];
+ [self.viewController.view removeObserver:self forKeyPath:@"bounds"];
+ }
+ @catch (NSException *exception) {
+ // When reloading the page from a remotely connected Safari, there
+ // are no observers, so the removeObserver method throws an exception,
+ // that we can safely ignore.
+ // Alternatively we can check whether there are observers before calling removeObserver
+ }
}
- (CDV_iOSDevice) getCurrentDevice
{
CDV_iOSDevice device;
-
+
UIScreen* mainScreen = [UIScreen mainScreen];
CGFloat mainScreenHeight = mainScreen.bounds.size.height;
CGFloat mainScreenWidth = mainScreen.bounds.size.width;
-
+
int limit = MAX(mainScreenHeight,mainScreenWidth);
-
+
device.iPad = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
device.iPhone = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone);
device.retina = ([mainScreen scale] == 2.0);
+ device.iPhone4 = (device.iPhone && limit == 480.0);
device.iPhone5 = (device.iPhone && limit == 568.0);
// note these below is not a true device detect, for example if you are on an
// iPhone 6/6+ but the app is scaled it will prob set iPhone5 as true, but
// this is appropriate for detecting the runtime screen environment
device.iPhone6 = (device.iPhone && limit == 667.0);
device.iPhone6Plus = (device.iPhone && limit == 736.0);
-
+
return device;
}
@@ -170,15 +182,15 @@
{
// Use UILaunchImageFile if specified in plist. Otherwise, use Default.
NSString* imageName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UILaunchImageFile"];
-
+
NSUInteger supportedOrientations = [orientationDelegate supportedInterfaceOrientations];
-
+
// Checks to see if the developer has locked the orientation to use only one of Portrait or Landscape
BOOL supportsLandscape = (supportedOrientations & UIInterfaceOrientationMaskLandscape);
BOOL supportsPortrait = (supportedOrientations & UIInterfaceOrientationMaskPortrait || supportedOrientations & UIInterfaceOrientationMaskPortraitUpsideDown);
// this means there are no mixed orientations in there
BOOL isOrientationLocked = !(supportsPortrait && supportsLandscape);
-
+
if (imageName)
{
imageName = [imageName stringByDeletingPathExtension];
@@ -187,7 +199,23 @@
{
imageName = @"Default";
}
-
+
+ // Add Asset Catalog specific prefixes
+ if ([imageName isEqualToString:@"LaunchImage"])
+ {
+ if (device.iPhone4 || device.iPhone5 || device.iPad) {
+ imageName = [imageName stringByAppendingString:@"-700"];
+ } else if(device.iPhone6) {
+ imageName = [imageName stringByAppendingString:@"-800"];
+ } else if(device.iPhone6Plus) {
+ imageName = [imageName stringByAppendingString:@"-800"];
+ if (currentOrientation == UIInterfaceOrientationPortrait || currentOrientation == UIInterfaceOrientationPortraitUpsideDown)
+ {
+ imageName = [imageName stringByAppendingString:@"-Portrait"];
+ }
+ }
+ }
+
if (device.iPhone5)
{ // does not support landscape
imageName = [imageName stringByAppendingString:@"-568h"];
@@ -231,7 +259,7 @@
case UIInterfaceOrientationLandscapeRight:
imageName = [imageName stringByAppendingString:@"-Landscape"];
break;
-
+
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationPortraitUpsideDown:
default:
@@ -240,14 +268,51 @@
}
}
}
-
+
return imageName;
}
+- (UIInterfaceOrientation)getCurrentOrientation
+{
+ UIInterfaceOrientation iOrientation = [UIApplication sharedApplication].statusBarOrientation;
+ UIDeviceOrientation dOrientation = [UIDevice currentDevice].orientation;
+
+ bool landscape;
+
+ if (dOrientation == UIDeviceOrientationUnknown || dOrientation == UIDeviceOrientationFaceUp || dOrientation == UIDeviceOrientationFaceDown) {
+ // If the device is laying down, use the UIInterfaceOrientation based on the status bar.
+ landscape = UIInterfaceOrientationIsLandscape(iOrientation);
+ } else {
+ // If the device is not laying down, use UIDeviceOrientation.
+ landscape = UIDeviceOrientationIsLandscape(dOrientation);
+
+ // There's a bug in iOS!!!! http://openradar.appspot.com/7216046
+ // So values needs to be reversed for landscape!
+ if (dOrientation == UIDeviceOrientationLandscapeLeft)
+ {
+ iOrientation = UIInterfaceOrientationLandscapeRight;
+ }
+ else if (dOrientation == UIDeviceOrientationLandscapeRight)
+ {
+ iOrientation = UIInterfaceOrientationLandscapeLeft;
+ }
+ else if (dOrientation == UIDeviceOrientationPortrait)
+ {
+ iOrientation = UIInterfaceOrientationPortrait;
+ }
+ else if (dOrientation == UIDeviceOrientationPortraitUpsideDown)
+ {
+ iOrientation = UIInterfaceOrientationPortraitUpsideDown;
+ }
+ }
+
+ return iOrientation;
+}
+
// Sets the view's frame and image.
- (void)updateImage
{
- NSString* imageName = [self getImageName:[[UIApplication sharedApplication] statusBarOrientation] delegate:(id<CDVScreenOrientationDelegate>)self.viewController device:[self getCurrentDevice]];
+ NSString* imageName = [self getImageName:[self getCurrentOrientation] delegate:(id<CDVScreenOrientationDelegate>)self.viewController device:[self getCurrentDevice]];
if (![imageName isEqualToString:_curImageName])
{
@@ -273,7 +338,7 @@
CGRect imgBounds = (img) ? CGRectMake(0, 0, img.size.width, img.size.height) : CGRectZero;
CGSize screenSize = [self.viewController.view convertRect:[UIScreen mainScreen].bounds fromView:nil].size;
- UIInterfaceOrientation orientation = self.viewController.interfaceOrientation;
+ UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
CGAffineTransform imgTransform = CGAffineTransformIdentity;
/* If and only if an iPhone application is landscape-only as per
@@ -281,8 +346,8 @@
* landscape. In this case the image must be rotated in order to appear
* correctly.
*/
- BOOL isIPad = [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad;
- if (UIInterfaceOrientationIsLandscape(orientation) && !isIPad)
+ CDV_iOSDevice device = [self getCurrentDevice];
+ if (UIInterfaceOrientationIsLandscape(orientation) && !device.iPhone6Plus && !device.iPad)
{
imgTransform = CGAffineTransformMakeRotation(M_PI / 2);
imgBounds.size = CGSizeMake(imgBounds.size.height, imgBounds.size.width);
@@ -322,26 +387,52 @@
- (void)setVisible:(BOOL)visible
{
- if (visible != _visible)
+ [self setVisible:visible andForce:NO];
+}
+
+- (void)setVisible:(BOOL)visible andForce:(BOOL)force
+{
+ if (visible != _visible || force)
{
_visible = visible;
id fadeSplashScreenValue = [self.commandDelegate.settings objectForKey:[@"FadeSplashScreen" lowercaseString]];
id fadeSplashScreenDuration = [self.commandDelegate.settings objectForKey:[@"FadeSplashScreenDuration" lowercaseString]];
- float fadeDuration = fadeSplashScreenDuration == nil ? kSplashScreenDurationDefault : [fadeSplashScreenDuration floatValue];
+ float fadeDuration = fadeSplashScreenDuration == nil ? kFadeDurationDefault : [fadeSplashScreenDuration floatValue];
+
+ id splashDurationString = [self.commandDelegate.settings objectForKey: [@"SplashScreenDelay" lowercaseString]];
+ float splashDuration = splashDurationString == nil ? kSplashScreenDurationDefault : [splashDurationString floatValue];
- if ((fadeSplashScreenValue == nil) || ![fadeSplashScreenValue boolValue])
+ id autoHideSplashScreenValue = [self.commandDelegate.settings objectForKey:[@"AutoHideSplashScreen" lowercaseString]];
+ BOOL autoHideSplashScreen = true;
+
+ if (autoHideSplashScreenValue != nil) {
+ autoHideSplashScreen = [autoHideSplashScreenValue boolValue];
+ }
+
+ if (!autoHideSplashScreen) {
+ // CB-10412 SplashScreenDelay does not make sense if the splashscreen is hidden manually
+ splashDuration = 0;
+ }
+
+
+ if (fadeSplashScreenValue == nil)
+ {
+ fadeSplashScreenValue = @"true";
+ }
+
+ if (![fadeSplashScreenValue boolValue])
{
fadeDuration = 0;
}
- else if(fadeDuration < 30)
+ else if (fadeDuration < 30)
{
// [CB-9750] This value used to be in decimal seconds, so we will assume that if someone specifies 10
// they mean 10 seconds, and not the meaningless 10ms
fadeDuration *= 1000;
}
-
+
if (_visible)
{
if (_imageView == nil)
@@ -349,26 +440,42 @@
[self createViews];
}
}
- else if (fadeDuration == 0)
+ else if (fadeDuration == 0 && splashDuration == 0)
{
[self destroyViews];
}
else
{
__weak __typeof(self) weakSelf = self;
- [UIView transitionWithView:self.viewController.view
- duration:(fadeDuration / 1000)
- options:UIViewAnimationOptionTransitionNone
- animations:^(void) {
- [weakSelf hideViews];
- }
- completion:^(BOOL finished) {
- if (finished) {
- [weakSelf destroyViews];
- // TODO: It might also be nice to have a js event happen here -jm
- }
- }
- ];
+ float effectiveSplashDuration;
+
+ // [CB-10562] AutoHideSplashScreen may be "true" but we should still be able to hide the splashscreen manually.
+ if (!autoHideSplashScreen || force) {
+ effectiveSplashDuration = (fadeDuration) / 1000;
+ } else {
+ effectiveSplashDuration = (splashDuration - fadeDuration) / 1000;
+ }
+
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (uint64_t) effectiveSplashDuration * NSEC_PER_SEC), dispatch_get_main_queue(), CFBridgingRelease(CFBridgingRetain(^(void) {
+ if (!_destroyed) {
+ [UIView transitionWithView:self.viewController.view
+ duration:(fadeDuration / 1000)
+ options:UIViewAnimationOptionTransitionNone
+ animations:^(void) {
+ [weakSelf hideViews];
+ }
+ completion:^(BOOL finished) {
+ // Always destroy views, otherwise you could have an
+ // invisible splashscreen that is overlayed over your active views
+ // which causes that no touch events are passed
+ if (!_destroyed) {
+ [weakSelf destroyViews];
+ // TODO: It might also be nice to have a js event happen here -jm
+ }
+ }
+ ];
+ }
+ })));
}
}
}
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-splashscreen/CDVViewController+SplashScreen.m b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-splashscreen/CDVViewController+SplashScreen.m
index 5736b6f2..e483def6 100644
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-splashscreen/CDVViewController+SplashScreen.m
+++ b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-splashscreen/CDVViewController+SplashScreen.m
@@ -35,6 +35,13 @@
- (BOOL)enabledAutorotation
{
NSNumber *number = (NSNumber *)objc_getAssociatedObject(self, @selector(enabledAutorotation));
+
+ // Defaulting to YES to correspond parent CDVViewController behavior
+ if (number == nil)
+ {
+ return YES;
+ }
+
return [number boolValue];
}
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-x-socialsharing/NSString+URLEncoding.h b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-x-socialsharing/NSString+URLEncoding.h
new file mode 100644
index 00000000..d7da331d
--- /dev/null
+++ b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-x-socialsharing/NSString+URLEncoding.h
@@ -0,0 +1,5 @@
+#import <Foundation/Foundation.h>
+
+@interface NSString (URLEncoding)
+@property (readonly) NSString *URLEncodedString;
+@end
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-x-socialsharing/NSString+URLEncoding.m b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-x-socialsharing/NSString+URLEncoding.m
new file mode 100644
index 00000000..b737626c
--- /dev/null
+++ b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-x-socialsharing/NSString+URLEncoding.m
@@ -0,0 +1,30 @@
+#import "NSString+URLEncoding.h"
+
+@implementation NSString (URLEncoding)
+- (NSString*)URLEncodedString
+{
+ NSString* result = (NSString *)CFBridgingRelease(
+ CFURLCreateStringByAddingPercentEscapes(
+ kCFAllocatorDefault,
+ (CFStringRef)self,
+ CFSTR("#%"), // don't escape these
+ NULL, // allow escaping these
+ kCFStringEncodingUTF8
+ )
+ );
+
+ // we may have a URL with more than one '#' now - which iOS doesn't allow, so escape all but the first one
+ NSArray *parts = [result componentsSeparatedByString:@"#"];
+ NSString *finalResult = parts[0];
+ for (int i=1; i<parts.count; i++) {
+ NSString *part = [parts objectAtIndex:i];
+ if (i==1) {
+ finalResult = [finalResult stringByAppendingString:@"#"];
+ } else {
+ finalResult = [finalResult stringByAppendingString:@"%23"];
+ }
+ finalResult = [finalResult stringByAppendingString:part];
+ }
+ return finalResult;
+}
+@end \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-x-socialsharing/SocialSharing.h b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-x-socialsharing/SocialSharing.h
index b51474d3..0c731450 100755..100644
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-x-socialsharing/SocialSharing.h
+++ b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-x-socialsharing/SocialSharing.h
@@ -4,13 +4,14 @@
@interface SocialSharing : CDVPlugin <UIPopoverControllerDelegate, MFMailComposeViewControllerDelegate, UIDocumentInteractionControllerDelegate>
@property (nonatomic, strong) MFMailComposeViewController *globalMailComposer;
-@property (retain) UIDocumentInteractionController * documentInteractionController;
+@property (nonatomic, strong) UIDocumentInteractionController * documentInteractionController;
@property (retain) NSString * tempStoredFile;
@property (retain) CDVInvokedUrlCommand * command;
- (void)available:(CDVInvokedUrlCommand*)command;
- (void)setIPadPopupCoordinates:(CDVInvokedUrlCommand*)command;
- (void)share:(CDVInvokedUrlCommand*)command;
+- (void)shareWithOptions:(CDVInvokedUrlCommand*)command;
- (void)canShareVia:(CDVInvokedUrlCommand*)command;
- (void)canShareViaEmail:(CDVInvokedUrlCommand*)command;
- (void)shareVia:(CDVInvokedUrlCommand*)command;
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-x-socialsharing/SocialSharing.m b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-x-socialsharing/SocialSharing.m
index cd0913a4..014925bd 100755..100644
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-x-socialsharing/SocialSharing.m
+++ b/StoneIsland/platforms/ios/Stone Island/Plugins/cordova-plugin-x-socialsharing/SocialSharing.m
@@ -1,4 +1,5 @@
#import "SocialSharing.h"
+#import "NSString+URLEncoding.h"
#import <Cordova/CDV.h>
#import <Social/Social.h>
#import <Foundation/NSException.h>
@@ -6,6 +7,11 @@
#import <MessageUI/MFMailComposeViewController.h>
#import <MobileCoreServices/MobileCoreServices.h>
+static NSString *const kShareOptionMessage = @"message";
+static NSString *const kShareOptionSubject = @"subject";
+static NSString *const kShareOptionFiles = @"files";
+static NSString *const kShareOptionUrl = @"url";
+
@implementation SocialSharing {
UIPopoverController *_popover;
NSString *_popupCoordinates;
@@ -51,23 +57,46 @@
}
- (void)share:(CDVInvokedUrlCommand*)command {
+ [self shareInternal:command
+ withOptions:@{
+ kShareOptionMessage: [command.arguments objectAtIndex:0],
+ kShareOptionSubject: [command.arguments objectAtIndex:1],
+ kShareOptionFiles: [command.arguments objectAtIndex:2],
+ kShareOptionUrl: [command.arguments objectAtIndex:3]
+ }
+ isBooleanResponse:YES
+];
+}
+
+- (void)shareWithOptions:(CDVInvokedUrlCommand*)command {
+ NSDictionary* options = [command.arguments objectAtIndex:0];
+ [self shareInternal:command
+ withOptions:options
+ isBooleanResponse:NO
+ ];
+}
+
+- (void)shareInternal:(CDVInvokedUrlCommand*)command withOptions:(NSDictionary*)options isBooleanResponse:(BOOL)boolResponse {
[self.commandDelegate runInBackground:^{ //avoid main thread block especially if sharing big files from url
if (!NSClassFromString(@"UIActivityViewController")) {
CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"not available"];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
return;
}
-
- NSString *message = [command.arguments objectAtIndex:0];
- NSString *subject = [command.arguments objectAtIndex:1];
- NSArray *filenames = [command.arguments objectAtIndex:2];
- NSString *urlString = [command.arguments objectAtIndex:3];
-
+
+ NSString *message = options[kShareOptionMessage];
+ NSString *subject = options[kShareOptionSubject];
+ NSArray *filenames = options[kShareOptionFiles];
+ NSString *urlString = options[kShareOptionUrl];
+
NSMutableArray *activityItems = [[NSMutableArray alloc] init];
+
+ if (message != (id)[NSNull null] && message != nil) {
[activityItems addObject:message];
-
- NSMutableArray *files = [[NSMutableArray alloc] init];
- if (filenames != (id)[NSNull null] && filenames.count > 0) {
+ }
+
+ if (filenames != (id)[NSNull null] && filenames != nil && filenames.count > 0) {
+ NSMutableArray *files = [[NSMutableArray alloc] init];
for (NSString* filename in filenames) {
NSObject *file = [self getImage:filename];
if (file == nil) {
@@ -79,31 +108,47 @@
}
[activityItems addObjectsFromArray:files];
}
-
- if (urlString != (id)[NSNull null]) {
- [activityItems addObject:[NSURL URLWithString:urlString]];
+
+ if (urlString != (id)[NSNull null] && urlString != nil) {
+ [activityItems addObject:[NSURL URLWithString:[urlString URLEncodedString]]];
}
-
+
UIActivity *activity = [[UIActivity alloc] init];
NSArray *applicationActivities = [[NSArray alloc] initWithObjects:activity, nil];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities];
- if (subject != (id)[NSNull null]) {
+ if (subject != (id)[NSNull null] && subject != nil) {
[activityVC setValue:subject forKey:@"subject"];
}
-
- // TODO deprecated in iOS 8.0, change this some day
- [activityVC setCompletionHandler:^(NSString *activityType, BOOL completed) {
- [self cleanupStoredFiles];
- NSLog(@"SocialSharing app selected: %@", activityType);
- CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:completed];
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
- }];
-
+
+ if ([activityVC respondsToSelector:(@selector(setCompletionWithItemsHandler:))]) {
+ [activityVC setCompletionWithItemsHandler:^(NSString *activityType, BOOL completed, NSArray * returnedItems, NSError * activityError) {
+ [self cleanupStoredFiles];
+ if (boolResponse) {
+ [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:completed]
+ callbackId:command.callbackId];
+ } else {
+ NSDictionary * result = @{@"completed":@(completed), @"app":activityType == nil ? @"" : activityType};
+ [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:result]
+ callbackId:command.callbackId];
+ }
+ }];
+ } else {
+ // let's suppress this warning otherwise folks will start opening issues while it's not relevant
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+ [activityVC setCompletionHandler:^(NSString *activityType, BOOL completed) {
+ [self cleanupStoredFiles];
+ NSDictionary * result = @{@"completed":@(completed), @"app":activityType};
+ CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:result];
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
+ }];
+#pragma GCC diagnostic warning "-Wdeprecated-declarations"
+ }
+
NSArray * socialSharingExcludeActivities = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"SocialSharingExcludeActivities"];
if (socialSharingExcludeActivities!=nil && [socialSharingExcludeActivities count] > 0) {
activityVC.excludedActivityTypes = socialSharingExcludeActivities;
}
-
+
dispatch_async(dispatch_get_main_queue(), ^(void){
// iPad on iOS >= 8 needs a different approach
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
@@ -230,27 +275,27 @@
- (void)shareViaInternal:(CDVInvokedUrlCommand*)command
type:(NSString *) type {
-
+
NSString *message = [command.arguments objectAtIndex:0];
// subject is not supported by the SLComposeViewController
NSArray *filenames = [command.arguments objectAtIndex:2];
NSString *urlString = [command.arguments objectAtIndex:3];
-
+
// boldly invoke the target app, because the phone will display a nice message asking to configure the app
SLComposeViewController *composeViewController = [SLComposeViewController composeViewControllerForServiceType:type];
if (message != (id)[NSNull null]) {
[composeViewController setInitialText:message];
}
-
+
for (NSString* filename in filenames) {
UIImage* image = [self getImage:filename];
if (image != nil) {
[composeViewController addImage:image];
}
}
-
+
if (urlString != (id)[NSNull null]) {
- [composeViewController addURL:[NSURL URLWithString:urlString]];
+ [composeViewController addURL:[NSURL URLWithString:[urlString URLEncodedString]]];
}
[composeViewController setCompletionHandler:^(SLComposeViewControllerResult result) {
@@ -272,7 +317,7 @@
- (void)shareViaEmail:(CDVInvokedUrlCommand*)command {
if ([self isEmailAvailable]) {
-
+
if (TARGET_IPHONE_SIMULATOR && IsAtLeastiOSVersion(@"8.0")) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"SocialSharing plugin"
message:@"Sharing via email is not supported on the iOS 8 simulator."
@@ -282,38 +327,40 @@
[alert show];
return;
}
-
+
+ [self cycleTheGlobalMailComposer];
+
self.globalMailComposer.mailComposeDelegate = self;
-
+
if ([command.arguments objectAtIndex:0] != (id)[NSNull null]) {
NSString *message = [command.arguments objectAtIndex:0];
BOOL isHTML = [message rangeOfString:@"<[^>]+>" options:NSRegularExpressionSearch].location != NSNotFound;
[self.globalMailComposer setMessageBody:message isHTML:isHTML];
}
-
+
if ([command.arguments objectAtIndex:1] != (id)[NSNull null]) {
[self.globalMailComposer setSubject: [command.arguments objectAtIndex:1]];
}
-
+
if ([command.arguments objectAtIndex:2] != (id)[NSNull null]) {
[self.globalMailComposer setToRecipients:[command.arguments objectAtIndex:2]];
}
-
+
if ([command.arguments objectAtIndex:3] != (id)[NSNull null]) {
[self.globalMailComposer setCcRecipients:[command.arguments objectAtIndex:3]];
}
-
+
if ([command.arguments objectAtIndex:4] != (id)[NSNull null]) {
[self.globalMailComposer setBccRecipients:[command.arguments objectAtIndex:4]];
}
-
+
if ([command.arguments objectAtIndex:5] != (id)[NSNull null]) {
NSArray* attachments = [command.arguments objectAtIndex:5];
NSFileManager* fileManager = [NSFileManager defaultManager];
for (NSString* path in attachments) {
NSURL *file = [self getFile:path];
NSData* data = [fileManager contentsAtPath:file.path];
-
+
NSString* fileName;
NSString* mimeType;
NSString* basename = [self getBasenameFromAttachmentPath:path];
@@ -331,14 +378,14 @@
[self.globalMailComposer addAttachmentData:data mimeType:mimeType fileName:fileName];
}
}
-
+
// remember the command, because we need it in the didFinishWithResult method
_command = command;
[self.commandDelegate runInBackground:^{
[[self getTopMostViewController] presentViewController:self.globalMailComposer animated:YES completion:nil];
}];
-
+
} else {
CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"not available"];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
@@ -358,7 +405,7 @@
NSString* pathWithoutPrefix = [path stringByReplacingOccurrencesOfString:@"base64:" withString:@""];
return [pathWithoutPrefix substringToIndex:[pathWithoutPrefix rangeOfString:@"//"].location];
}
- return path;
+ return [path componentsSeparatedByString: @"?"][0];
}
- (NSString*) getMimeTypeFromFileExtension:(NSString*)extension {
@@ -406,7 +453,7 @@
NSString *message = [options objectForKey:@"message"];
NSString *subject = [options objectForKey:@"subject"];
NSString *image = [options objectForKey:@"image"];
-
+
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = (id) self;
if (message != (id)[NSNull null]) {
@@ -424,7 +471,7 @@
}
}
}
-
+
if (phonenumbers != (id)[NSNull null]) {
[picker setRecipients:[phonenumbers componentsSeparatedByString:@","]];
}
@@ -469,7 +516,7 @@
}
- (void)shareViaInstagram:(CDVInvokedUrlCommand*)command {
-
+
// on iOS9 canShareVia('instagram'..) will only work if instagram:// is whitelisted.
// If it's not, this method will ask permission to the user on iOS9 for opening the app,
// which is of course better than Instagram sharing not working at all because you forgot to whitelist it.
@@ -492,7 +539,7 @@
image = [self getImage:filename];
break;
}
-
+
// NSData *imageObj = [NSData dataFromBase64String:objectAtIndex0];
NSString *tmpDir = NSTemporaryDirectory();
NSString *path = [tmpDir stringByAppendingPathComponent:@"instagram.igo"];
@@ -513,11 +560,15 @@
// remember the command for the delegate method
_command = command;
- [_documentInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.webView animated:YES];
+
+ // test for #513
+ dispatch_async(dispatch_get_main_queue(), ^(void){
+ [_documentInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.webView animated:YES];
+ });
}
- (void)shareViaWhatsApp:(CDVInvokedUrlCommand*)command {
-
+
// on iOS9 canShareVia('whatsapp'..) will only work if whatsapp:// is whitelisted.
// If it's not, this method will ask permission to the user on iOS9 for opening the app,
// which is of course better than WhatsApp sharing not working at all because you forgot to whitelist it.
@@ -534,6 +585,7 @@
// subject is not supported by the SLComposeViewController
NSArray *filenames = [command.arguments objectAtIndex:2];
NSString *urlString = [command.arguments objectAtIndex:3];
+ NSString *abid = [command.arguments objectAtIndex:4];
// only use the first image (for now.. maybe we can share in a loop?)
UIImage* image = nil;
@@ -561,14 +613,18 @@
if ([shareString isEqual: @""]) {
shareString = urlString;
} else {
- shareString = [NSString stringWithFormat:@"%@ %@", shareString, urlString];
+ shareString = [NSString stringWithFormat:@"%@ %@", shareString, [urlString URLEncodedString]];
}
}
NSString * encodedShareString = [shareString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
// also encode the '=' character
encodedShareString = [encodedShareString stringByReplacingOccurrencesOfString:@"=" withString:@"%3D"];
encodedShareString = [encodedShareString stringByReplacingOccurrencesOfString:@"&" withString:@"%26"];
- NSString * encodedShareStringForWhatsApp = [NSString stringWithFormat:@"whatsapp://send?text=%@", encodedShareString];
+ NSString * abidString = @"";
+ if (abid != (id)[NSNull null]) {
+ abidString = [NSString stringWithFormat:@"abid=%@&", abid];
+ }
+ NSString * encodedShareStringForWhatsApp = [NSString stringWithFormat:@"whatsapp://send?%@text=%@", abidString, encodedShareString];
NSURL *whatsappURL = [NSURL URLWithString:encodedShareStringForWhatsApp];
[[UIApplication sharedApplication] openURL: whatsappURL];
@@ -641,7 +697,8 @@
if ([fileName hasPrefix:@"http"]) {
NSURL *url = [NSURL URLWithString:fileName];
NSData *fileData = [NSData dataWithContentsOfURL:url];
- file = [NSURL fileURLWithPath:[self storeInFile:(NSString*)[[fileName componentsSeparatedByString: @"/"] lastObject] fileData:fileData]];
+ NSString *name = (NSString*)[[fileName componentsSeparatedByString: @"/"] lastObject];
+ file = [NSURL fileURLWithPath:[self storeInFile:[name componentsSeparatedByString: @"?"][0] fileData:fileData]];
} else if ([fileName hasPrefix:@"www/"]) {
NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
NSString *fullPath = [NSString stringWithFormat:@"%@/%@", bundlePath, fileName];
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/com.ionic.keyboard/IonicKeyboard.h b/StoneIsland/platforms/ios/Stone Island/Plugins/ionic-plugin-keyboard/IonicKeyboard.h
index b54f430d..63935dc3 100755..100644
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/com.ionic.keyboard/IonicKeyboard.h
+++ b/StoneIsland/platforms/ios/Stone Island/Plugins/ionic-plugin-keyboard/IonicKeyboard.h
@@ -1,8 +1,11 @@
#import <Cordova/CDVPlugin.h>
+#import <objc/runtime.h>
@interface IonicKeyboard : CDVPlugin <UIScrollViewDelegate> {
@protected
id _keyboardShowObserver, _keyboardHideObserver;
+ IMP wkOriginalImp, uiOriginalImp, nilImp;
+ Method wkMethod, uiMethod;
}
@property (readwrite, assign) BOOL hideKeyboardAccessoryBar;
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/com.ionic.keyboard/IonicKeyboard.m b/StoneIsland/platforms/ios/Stone Island/Plugins/ionic-plugin-keyboard/IonicKeyboard.m
index 045cc65f..d072ca7f 100755..100644
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/com.ionic.keyboard/IonicKeyboard.m
+++ b/StoneIsland/platforms/ios/Stone Island/Plugins/ionic-plugin-keyboard/IonicKeyboard.m
@@ -1,5 +1,5 @@
#import "IonicKeyboard.h"
-#import "UIWebViewExtension.h"
+// #import "UIWebViewExtension.h"
#import <Cordova/CDVAvailability.h>
@implementation IonicKeyboard
@@ -9,29 +9,38 @@
//@synthesize styleDark = _styleDark;
- (void)pluginInitialize {
-
- NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
- __weak IonicKeyboard* weakSelf = self;
+ Class wkClass = NSClassFromString([@[@"UI", @"Web", @"Browser", @"View"] componentsJoinedByString:@""]);
+ wkMethod = class_getInstanceMethod(wkClass, @selector(inputAccessoryView));
+ wkOriginalImp = method_getImplementation(wkMethod);
+ Class uiClass = NSClassFromString([@[@"WK", @"Content", @"View"] componentsJoinedByString:@""]);
+ uiMethod = class_getInstanceMethod(uiClass, @selector(inputAccessoryView));
+ uiOriginalImp = method_getImplementation(uiMethod);
+ nilImp = imp_implementationWithBlock(^(id _s) {
+ return nil;
+ });
+
//set defaults
- self.hideKeyboardAccessoryBar = NO;
+ self.hideKeyboardAccessoryBar = YES;
self.disableScroll = NO;
//self.styleDark = NO;
+ NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
+ __weak IonicKeyboard* weakSelf = self;
_keyboardShowObserver = [nc addObserverForName:UIKeyboardWillShowNotification
object:nil
queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification* notification) {
-
+
CGRect keyboardFrame = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
keyboardFrame = [self.viewController.view convertRect:keyboardFrame fromView:nil];
-
+
[weakSelf.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.plugins.Keyboard.isVisible = true; cordova.fireWindowEvent('native.keyboardshow', { 'keyboardHeight': %@ }); ", [@(keyboardFrame.size.height) stringValue]]];
//deprecated
[weakSelf.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireWindowEvent('native.showkeyboard', { 'keyboardHeight': %@ }); ", [@(keyboardFrame.size.height) stringValue]]];
}];
-
+
_keyboardHideObserver = [nc addObserverForName:UIKeyboardWillHideNotification
object:nil
queue:[NSOperationQueue mainQueue]
@@ -42,6 +51,7 @@
[weakSelf.commandDelegate evalJs:@"cordova.fireWindowEvent('native.hidekeyboard'); "];
}];
}
+
- (BOOL)disableScroll {
return _disableScroll;
}
@@ -62,6 +72,8 @@
_disableScroll = disableScroll;
}
+//keyboard swizzling inspired by:
+//https://github.com/cjpearson/cordova-plugin-keyboard/
- (BOOL)hideKeyboardAccessoryBar {
return _hideKeyboardAccessoryBar;
@@ -71,13 +83,15 @@
if (hideKeyboardAccessoryBar == _hideKeyboardAccessoryBar) {
return;
}
+
if (hideKeyboardAccessoryBar) {
- self.webView.hackishlyHidesInputAccessoryView = YES;
+ method_setImplementation(wkMethod, nilImp);
+ method_setImplementation(uiMethod, nilImp);
+ } else {
+ method_setImplementation(wkMethod, wkOriginalImp);
+ method_setImplementation(uiMethod, uiOriginalImp);
}
- else {
- self.webView.hackishlyHidesInputAccessoryView = NO;
- }
-
+
_hideKeyboardAccessoryBar = hideKeyboardAccessoryBar;
}
@@ -124,17 +138,19 @@
return;
}
id value = [command.arguments objectAtIndex:0];
-
- self.disableScroll = [value boolValue];
+ if (value != [NSNull null]) {
+ self.disableScroll = [value boolValue];
+ }
}
- (void) hideKeyboardAccessoryBar:(CDVInvokedUrlCommand*)command {
if (!command.arguments || ![command.arguments count]){
- return;
+ return;
}
id value = [command.arguments objectAtIndex:0];
-
- self.hideKeyboardAccessoryBar = [value boolValue];
+ if (value != [NSNull null]) {
+ self.hideKeyboardAccessoryBar = [value boolValue];
+ }
}
- (void) close:(CDVInvokedUrlCommand*)command {
@@ -151,7 +167,7 @@
return;
}
id value = [command.arguments objectAtIndex:0];
-
+
self.styleDark = [value boolValue];
}
*/
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/phonegap-plugin-push/AppDelegate+notification.h b/StoneIsland/platforms/ios/Stone Island/Plugins/phonegap-plugin-push/AppDelegate+notification.h
deleted file mode 100755
index be79903e..00000000
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/phonegap-plugin-push/AppDelegate+notification.h
+++ /dev/null
@@ -1,21 +0,0 @@
-//
-// AppDelegate+notification.h
-// pushtest
-//
-// Created by Robert Easterday on 10/26/12.
-//
-//
-
-#import "AppDelegate.h"
-
-@interface AppDelegate (notification)
-- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken;
-- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error;
-- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo;
-- (void)applicationDidBecomeActive:(UIApplication *)application;
-- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler;
-- (id) getCommandInstance:(NSString*)className;
-
-@property (nonatomic, retain) NSDictionary *launchNotification;
-
-@end
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/phonegap-plugin-push/AppDelegate+notification.m b/StoneIsland/platforms/ios/Stone Island/Plugins/phonegap-plugin-push/AppDelegate+notification.m
deleted file mode 100755
index 8b4ed161..00000000
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/phonegap-plugin-push/AppDelegate+notification.m
+++ /dev/null
@@ -1,167 +0,0 @@
-//
-// AppDelegate+notification.m
-// pushtest
-//
-// Created by Robert Easterday on 10/26/12.
-//
-//
-
-#import "AppDelegate+notification.h"
-#import "PushPlugin.h"
-#import <objc/runtime.h>
-
-static char launchNotificationKey;
-
-@implementation AppDelegate (notification)
-
-- (id) getCommandInstance:(NSString*)className
-{
- return [self.viewController getCommandInstance:className];
-}
-
-// its dangerous to override a method from within a category.
-// Instead we will use method swizzling. we set this up in the load call.
-+ (void)load
-{
- Method original, swizzled;
-
- original = class_getInstanceMethod(self, @selector(init));
- swizzled = class_getInstanceMethod(self, @selector(swizzled_init));
- method_exchangeImplementations(original, swizzled);
-}
-
-- (AppDelegate *)swizzled_init
-{
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(createNotificationChecker:)
- name:@"UIApplicationDidFinishLaunchingNotification" object:nil];
-
- // This actually calls the original init method over in AppDelegate. Equivilent to calling super
- // on an overrided method, this is not recursive, although it appears that way. neat huh?
- return [self swizzled_init];
-}
-
-// This code will be called immediately after application:didFinishLaunchingWithOptions:. We need
-// to process notifications in cold-start situations
-- (void)createNotificationChecker:(NSNotification *)notification
-{
- if (notification)
- {
- NSDictionary *launchOptions = [notification userInfo];
- if (launchOptions)
- self.launchNotification = [launchOptions objectForKey: @"UIApplicationLaunchOptionsRemoteNotificationKey"];
- }
-}
-
-- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
- PushPlugin *pushHandler = [self getCommandInstance:@"PushNotification"];
- [pushHandler didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
-}
-
-- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
- PushPlugin *pushHandler = [self getCommandInstance:@"PushNotification"];
- [pushHandler didFailToRegisterForRemoteNotificationsWithError:error];
-}
-
-- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
- NSLog(@"didReceiveNotification with fetchCompletionHandler");
-
- // app is in the foreground so call notification callback
- if (application.applicationState == UIApplicationStateActive) {
- NSLog(@"app active");
- PushPlugin *pushHandler = [self getCommandInstance:@"PushNotification"];
- pushHandler.notificationMessage = userInfo;
- pushHandler.isInline = YES;
- [pushHandler notificationReceived];
-
- completionHandler(UIBackgroundFetchResultNewData);
- }
- // app is in background or in stand by
- else {
- NSLog(@"app in-active");
-
- // do some convoluted logic to find out if this should be a silent push.
- long silent = 0;
- id aps = [userInfo objectForKey:@"aps"];
- id contentAvailable = [aps objectForKey:@"content-available"];
- if ([contentAvailable isKindOfClass:[NSString class]] && [contentAvailable isEqualToString:@"1"]) {
- silent = 1;
- } else if ([contentAvailable isKindOfClass:[NSNumber class]]) {
- silent = [contentAvailable integerValue];
- }
-
- if (silent == 1) {
- NSLog(@"this should be a silent push");
- void (^safeHandler)(UIBackgroundFetchResult) = ^(UIBackgroundFetchResult result){
- dispatch_async(dispatch_get_main_queue(), ^{
- completionHandler(result);
- });
- };
-
- NSMutableDictionary* params = [NSMutableDictionary dictionaryWithCapacity:2];
- [params setObject:safeHandler forKey:@"handler"];
-
- PushPlugin *pushHandler = [self getCommandInstance:@"PushNotification"];
- pushHandler.notificationMessage = userInfo;
- pushHandler.isInline = NO;
- pushHandler.handlerObj = params;
- [pushHandler notificationReceived];
- } else {
- NSLog(@"just put it in the shade");
- //save it for later
- self.launchNotification = userInfo;
-
- completionHandler(UIBackgroundFetchResultNewData);
- }
- }
-}
-
-- (void)applicationDidBecomeActive:(UIApplication *)application {
-
- NSLog(@"active");
-
- PushPlugin *pushHandler = [self getCommandInstance:@"PushNotification"];
- if (pushHandler.clearBadge) {
- NSLog(@"PushPlugin clearing badge");
- //zero badge
- application.applicationIconBadgeNumber = 0;
- } else {
- NSLog(@"PushPlugin skip clear badge");
- }
-
- if (self.launchNotification) {
- pushHandler.isInline = NO;
- pushHandler.notificationMessage = self.launchNotification;
- self.launchNotification = nil;
- [pushHandler performSelectorOnMainThread:@selector(notificationReceived) withObject:pushHandler waitUntilDone:NO];
- }
-}
-
-//For interactive notification only
-- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler
-{
- //handle the actions
- if ([identifier isEqualToString:@"declineAction"]){
- }
- else if ([identifier isEqualToString:@"answerAction"]){
- }
-}
-
-
-// The accessors use an Associative Reference since you can't define a iVar in a category
-// http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/objectivec/Chapters/ocAssociativeReferences.html
-- (NSMutableArray *)launchNotification
-{
- return objc_getAssociatedObject(self, &launchNotificationKey);
-}
-
-- (void)setLaunchNotification:(NSDictionary *)aDictionary
-{
- objc_setAssociatedObject(self, &launchNotificationKey, aDictionary, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
-}
-
-- (void)dealloc
-{
- self.launchNotification = nil; // clear the association and release the object
-}
-
-@end
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/phonegap-plugin-push/PushPlugin.h b/StoneIsland/platforms/ios/Stone Island/Plugins/phonegap-plugin-push/PushPlugin.h
deleted file mode 100755
index 5b88398e..00000000
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/phonegap-plugin-push/PushPlugin.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- Copyright 2009-2011 Urban Airship Inc. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
-
- 2. Redistributions in binaryform must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided withthe distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE URBAN AIRSHIP INC``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- EVENT SHALL URBAN AIRSHIP INC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Foundation/Foundation.h>
-#import <Cordova/CDV.h>
-#import <Cordova/CDVPlugin.h>
-
-@interface PushPlugin : CDVPlugin
-{
- NSDictionary *notificationMessage;
- BOOL isInline;
- NSString *notificationCallbackId;
- NSString *callback;
- BOOL clearBadge;
-
- NSDictionary *handlerObj;
- void (^completionHandler)(UIBackgroundFetchResult);
-
- BOOL ready;
-}
-
-@property (nonatomic, copy) NSString *callbackId;
-@property (nonatomic, copy) NSString *notificationCallbackId;
-@property (nonatomic, copy) NSString *callback;
-
-@property (nonatomic, strong) NSDictionary *notificationMessage;
-@property BOOL isInline;
-@property BOOL clearBadge;
-@property (nonatomic, strong) NSDictionary *handlerObj;
-
-- (void)init:(CDVInvokedUrlCommand*)command;
-- (void)unregister:(CDVInvokedUrlCommand*)command;
-
-- (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken;
-- (void)didFailToRegisterForRemoteNotificationsWithError:(NSError *)error;
-
-- (void)setNotificationMessage:(NSDictionary *)notification;
-- (void)notificationReceived;
-
-@end
diff --git a/StoneIsland/platforms/ios/Stone Island/Plugins/phonegap-plugin-push/PushPlugin.m b/StoneIsland/platforms/ios/Stone Island/Plugins/phonegap-plugin-push/PushPlugin.m
deleted file mode 100755
index 40f494d1..00000000
--- a/StoneIsland/platforms/ios/Stone Island/Plugins/phonegap-plugin-push/PushPlugin.m
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- Copyright 2009-2011 Urban Airship Inc. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
-
- 2. Redistributions in binaryform must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided withthe distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE URBAN AIRSHIP INC``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- EVENT SHALL URBAN AIRSHIP INC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "PushPlugin.h"
-
-@implementation PushPlugin
-
-@synthesize notificationMessage;
-@synthesize isInline;
-
-@synthesize callbackId;
-@synthesize notificationCallbackId;
-@synthesize callback;
-@synthesize clearBadge;
-@synthesize handlerObj;
-
-- (void)unregister:(CDVInvokedUrlCommand*)command;
-{
- self.callbackId = command.callbackId;
-
- [[UIApplication sharedApplication] unregisterForRemoteNotifications];
- [self successWithMessage:@"unregistered"];
-}
-
-- (void)init:(CDVInvokedUrlCommand*)command;
-{
- [self.commandDelegate runInBackground:^ {
-
- NSLog(@"Push Plugin register called");
- self.callbackId = command.callbackId;
-
- NSMutableDictionary* options = [command.arguments objectAtIndex:0];
- NSMutableDictionary* iosOptions = [options objectForKey:@"ios"];
-
-#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
- UIUserNotificationType UserNotificationTypes = UIUserNotificationTypeNone;
-#endif
- UIRemoteNotificationType notificationTypes = UIRemoteNotificationTypeNone;
-
- id badgeArg = [iosOptions objectForKey:@"badge"];
- id soundArg = [iosOptions objectForKey:@"sound"];
- id alertArg = [iosOptions objectForKey:@"alert"];
- id clearBadgeArg = [iosOptions objectForKey:@"clearBadge"];
-
- if (([badgeArg isKindOfClass:[NSString class]] && [badgeArg isEqualToString:@"true"]) || [badgeArg boolValue])
- {
- notificationTypes |= UIRemoteNotificationTypeBadge;
-#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
- UserNotificationTypes |= UIUserNotificationTypeBadge;
-#endif
- }
-
- if (([soundArg isKindOfClass:[NSString class]] && [soundArg isEqualToString:@"true"]) || [soundArg boolValue])
- {
- notificationTypes |= UIRemoteNotificationTypeSound;
-#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
- UserNotificationTypes |= UIUserNotificationTypeSound;
-#endif
- }
-
- if (([alertArg isKindOfClass:[NSString class]] && [alertArg isEqualToString:@"true"]) || [alertArg boolValue])
- {
- notificationTypes |= UIRemoteNotificationTypeAlert;
-#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
- UserNotificationTypes |= UIUserNotificationTypeAlert;
-#endif
- }
-
- notificationTypes |= UIRemoteNotificationTypeNewsstandContentAvailability;
-#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
- UserNotificationTypes |= UIUserNotificationActivationModeBackground;
-#endif
-
- if (clearBadgeArg == nil || ([clearBadgeArg isKindOfClass:[NSString class]] && [clearBadgeArg isEqualToString:@"false"]) || ![clearBadgeArg boolValue]) {
- NSLog(@"PushPlugin.register: setting badge to false");
- clearBadge = NO;
- } else {
- NSLog(@"PushPlugin.register: setting badge to true");
- clearBadge = YES;
- [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
- }
- NSLog(@"PushPlugin.register: clear badge is set to %d", clearBadge);
-
- if (notificationTypes == UIRemoteNotificationTypeNone)
- NSLog(@"PushPlugin.register: Push notification type is set to none");
-
- isInline = NO;
-
-#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
- if ([[UIApplication sharedApplication]respondsToSelector:@selector(registerUserNotificationSettings:)]) {
- UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UserNotificationTypes categories:nil];
- [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
- [[UIApplication sharedApplication] registerForRemoteNotifications];
- } else {
- [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
- (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
- }
-#else
- [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
- (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
-#endif
-
- if (notificationMessage) // if there is a pending startup notification
- [self notificationReceived]; // go ahead and process it
-
- }];
-}
-
-- (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
- if (self.callbackId == nil) {
- NSLog(@"Unexpected call to didRegisterForRemoteNotificationsWithDeviceToken, ignoring: %@", deviceToken);
- return;
- }
- NSLog(@"Push Plugin register success: %@", deviceToken);
-
- NSMutableDictionary *results = [NSMutableDictionary dictionary];
- NSString *token = [[[[deviceToken description] stringByReplacingOccurrencesOfString:@"<"withString:@""]
- stringByReplacingOccurrencesOfString:@">" withString:@""]
- stringByReplacingOccurrencesOfString: @" " withString: @""];
- [results setValue:token forKey:@"deviceToken"];
-
-#if !TARGET_IPHONE_SIMULATOR
- // Get Bundle Info for Remote Registration (handy if you have more than one app)
- [results setValue:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"] forKey:@"appName"];
- [results setValue:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] forKey:@"appVersion"];
-
- // Check what Notifications the user has turned on. We registered for all three, but they may have manually disabled some or all of them.
-#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
-
- NSUInteger rntypes;
- if (!SYSTEM_VERSION_LESS_THAN(@"8.0")) {
- rntypes = [[[UIApplication sharedApplication] currentUserNotificationSettings] types];
- } else {
- rntypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
- }
-
- // Set the defaults to disabled unless we find otherwise...
- NSString *pushBadge = @"disabled";
- NSString *pushAlert = @"disabled";
- NSString *pushSound = @"disabled";
-
- // Check what Registered Types are turned on. This is a bit tricky since if two are enabled, and one is off, it will return a number 2... not telling you which
- // one is actually disabled. So we are literally checking to see if rnTypes matches what is turned on, instead of by number. The "tricky" part is that the
- // single notification types will only match if they are the ONLY one enabled. Likewise, when we are checking for a pair of notifications, it will only be
- // true if those two notifications are on. This is why the code is written this way
- if(rntypes & UIRemoteNotificationTypeBadge){
- pushBadge = @"enabled";
- }
- if(rntypes & UIRemoteNotificationTypeAlert) {
- pushAlert = @"enabled";
- }
- if(rntypes & UIRemoteNotificationTypeSound) {
- pushSound = @"enabled";
- }
-
- [results setValue:pushBadge forKey:@"pushBadge"];
- [results setValue:pushAlert forKey:@"pushAlert"];
- [results setValue:pushSound forKey:@"pushSound"];
-
- // Get the users Device Model, Display Name, Token & Version Number
- UIDevice *dev = [UIDevice currentDevice];
- [results setValue:dev.name forKey:@"deviceName"];
- [results setValue:dev.model forKey:@"deviceModel"];
- [results setValue:dev.systemVersion forKey:@"deviceSystemVersion"];
-
- // Send result to trigger 'registration' event but keep callback
- NSMutableDictionary* message = [NSMutableDictionary dictionaryWithCapacity:1];
- [message setObject:token forKey:@"registrationId"];
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:message];
- [pluginResult setKeepCallbackAsBool:YES];
- [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
-#endif
-}
-
-- (void)didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
-{
- if (self.callbackId == nil) {
- NSLog(@"Unexpected call to didFailToRegisterForRemoteNotificationsWithError, ignoring: %@", error);
- return;
- }
- NSLog(@"Push Plugin register failed");
- [self failWithMessage:@"" withError:error];
-}
-
-- (void)notificationReceived {
- NSLog(@"Notification received");
-
- if (notificationMessage && self.callbackId != nil)
- {
- NSMutableDictionary* message = [NSMutableDictionary dictionaryWithCapacity:4];
- NSMutableDictionary* additionalData = [NSMutableDictionary dictionaryWithCapacity:4];
-
-
- for (id key in notificationMessage) {
- if ([key isEqualToString:@"aps"]) {
- id aps = [notificationMessage objectForKey:@"aps"];
-
- for(id key in aps) {
- NSLog(@"Push Plugin key: %@", key);
- id value = [aps objectForKey:key];
-
- if ([key isEqualToString:@"alert"]) {
- if ([value isKindOfClass:[NSDictionary class]]) {
- for (id messageKey in value) {
- id messageValue = [value objectForKey:messageKey];
- if ([messageKey isEqualToString:@"body"]) {
- [message setObject:messageValue forKey:@"message"];
- } else if ([messageKey isEqualToString:@"title"]) {
- [message setObject:messageValue forKey:@"title"];
- } else {
- [additionalData setObject:messageValue forKey:messageKey];
- }
- }
- }
- else {
- [message setObject:value forKey:@"message"];
- }
- } else if ([key isEqualToString:@"title"]) {
- [message setObject:value forKey:@"title"];
- } else if ([key isEqualToString:@"badge"]) {
- [message setObject:value forKey:@"count"];
- } else if ([key isEqualToString:@"sound"]) {
- [message setObject:value forKey:@"sound"];
- } else if ([key isEqualToString:@"image"]) {
- [message setObject:value forKey:@"image"];
- } else {
- [additionalData setObject:value forKey:key];
- }
- }
- } else {
- [additionalData setObject:[notificationMessage objectForKey:key] forKey:key];
- }
- }
-
- if (isInline) {
- [additionalData setObject:[NSNumber numberWithBool:YES] forKey:@"foreground"];
- } else {
- [additionalData setObject:[NSNumber numberWithBool:NO] forKey:@"foreground"];
- }
-
- [message setObject:additionalData forKey:@"additionalData"];
-
- // send notification message
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:message];
- [pluginResult setKeepCallbackAsBool:YES];
- [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
-
- self.notificationMessage = nil;
- }
-}
-
-- (void)setApplicationIconBadgeNumber:(CDVInvokedUrlCommand *)command
-{
- NSMutableDictionary* options = [command.arguments objectAtIndex:0];
- int badge = [[options objectForKey:@"badge"] intValue] ?: 0;
-
- [[UIApplication sharedApplication] setApplicationIconBadgeNumber:badge];
-
- NSString* message = [NSString stringWithFormat:@"app badge count set to %d", badge];
- CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:message];
- [self.commandDelegate sendPluginResult:commandResult callbackId:command.callbackId];
-}
-
-- (void)getApplicationIconBadgeNumber:(CDVInvokedUrlCommand *)command
-{
- NSInteger badge = [UIApplication sharedApplication].applicationIconBadgeNumber;
-
- CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:(int)badge];
- [self.commandDelegate sendPluginResult:commandResult callbackId:command.callbackId];
-}
-
--(void)successWithMessage:(NSString *)message
-{
- if (self.callbackId != nil)
- {
- CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:message];
- [self.commandDelegate sendPluginResult:commandResult callbackId:self.callbackId];
- }
-}
-
--(void)failWithMessage:(NSString *)message withError:(NSError *)error
-{
- NSString *errorMessage = (error) ? [NSString stringWithFormat:@"%@ - %@", message, [error localizedDescription]] : message;
- CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:errorMessage];
-
- [self.commandDelegate sendPluginResult:commandResult callbackId:self.callbackId];
-}
-
--(void) finish:(CDVInvokedUrlCommand*)command
-{
- NSLog(@"Push Plugin finish called");
-
- [self.commandDelegate runInBackground:^ {
- UIApplication *app = [UIApplication sharedApplication];
- float finishTimer = (app.backgroundTimeRemaining > 20.0) ? 20.0 : app.backgroundTimeRemaining;
-
- [NSTimer scheduledTimerWithTimeInterval:finishTimer
- target:self
- selector:@selector(stopBackgroundTask:)
- userInfo:nil
- repeats:NO];
-
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
- }];
-}
-
--(void)stopBackgroundTask:(NSTimer*)timer
-{
- UIApplication *app = [UIApplication sharedApplication];
-
- NSLog(@"Push Plugin stopBackgroundTask called");
-
- if (handlerObj) {
- NSLog(@"Push Plugin handlerObj");
- completionHandler = [handlerObj[@"handler"] copy];
- if (completionHandler) {
- NSLog(@"Push Plugin: stopBackgroundTask (remaining t: %f)", app.backgroundTimeRemaining);
- completionHandler(UIBackgroundFetchResultNewData);
- completionHandler = nil;
- }
- }
-}
-
-@end