diff --git a/iphone/Classes/TiUIApplicationShortcutsProxy.m b/iphone/Classes/TiUIApplicationShortcutsProxy.m index 3768d251cce..9896ea00aff 100644 --- a/iphone/Classes/TiUIApplicationShortcutsProxy.m +++ b/iphone/Classes/TiUIApplicationShortcutsProxy.m @@ -212,7 +212,7 @@ - (UIApplicationShortcutIcon *)findIcon:(id)value return [UIApplicationShortcutIcon iconWithTemplateImageName:[self urlInAssetCatalog:value]]; } -#ifdef IS_SDK_IOS_13 +#if IS_SDK_IOS_13 if ([value isKindOfClass:[TiBlob class]] && [TiUtils isIOSVersionOrGreater:@"13.0"]) { TiBlob *blob = (TiBlob *)value; if (blob.type == TiBlobTypeSystemImage) { diff --git a/iphone/Classes/TiUIiOSApplicationShortcutsProxy.m b/iphone/Classes/TiUIiOSApplicationShortcutsProxy.m index cd355a1c00b..82f3bcd5eff 100644 --- a/iphone/Classes/TiUIiOSApplicationShortcutsProxy.m +++ b/iphone/Classes/TiUIiOSApplicationShortcutsProxy.m @@ -212,7 +212,7 @@ - (UIApplicationShortcutIcon *)findIcon:(id)value return [UIApplicationShortcutIcon iconWithTemplateImageName:[self urlInAssetCatalog:value]]; } -#ifdef IS_SDK_IOS_13 +#if IS_SDK_IOS_13 if ([value isKindOfClass:[TiBlob class]] && [TiUtils isIOSVersionOrGreater:@"13.0"]) { TiBlob *blob = (TiBlob *)value; if (blob.type == TiBlobTypeSystemImage) { diff --git a/iphone/TitaniumKit/TitaniumKit/Sources/API/KrollBridge.m b/iphone/TitaniumKit/TitaniumKit/Sources/API/KrollBridge.m index 547db38e8b0..97c2de386f0 100644 --- a/iphone/TitaniumKit/TitaniumKit/Sources/API/KrollBridge.m +++ b/iphone/TitaniumKit/TitaniumKit/Sources/API/KrollBridge.m @@ -872,12 +872,6 @@ - (KrollWrapper *)loadJavascriptText:(NSString *)data fromFile:(NSString *)filen userInfo:nil]; } - if (filename != nil && module != nil) { - // uri is optional but we point it to where we loaded it - [module replaceValue:[NSString stringWithFormat:@"app://%@", filename] forKey:@"uri" notification:NO]; - [module replaceValue:filename forKey:@"id" notification:NO]; // set id to full path, originally this was the path from require call - } - return module; } diff --git a/iphone/TitaniumKit/TitaniumKit/Sources/API/TiApp.m b/iphone/TitaniumKit/TitaniumKit/Sources/API/TiApp.m index 700b647b900..b29acfd80e8 100644 --- a/iphone/TitaniumKit/TitaniumKit/Sources/API/TiApp.m +++ b/iphone/TitaniumKit/TitaniumKit/Sources/API/TiApp.m @@ -432,7 +432,12 @@ - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDiction [launchOptions setObject:[url absoluteString] forKey:@"url"]; [launchOptions removeObjectForKey:UIApplicationLaunchOptionsSourceApplicationKey]; - [launchOptions setObject:[options objectForKey:UIApplicationOpenURLOptionsSourceApplicationKey] ?: [NSNull null] forKey:@"source"]; + id source = [options objectForKey:UIApplicationOpenURLOptionsSourceApplicationKey]; + if (source != nil) { + [launchOptions setObject:source forKey:@"source"]; + } else { + [launchOptions removeObjectForKey:@"source"]; + } if (appBooted) { [[NSNotificationCenter defaultCenter] postNotificationName:kTiApplicationLaunchedFromURL object:self userInfo:launchOptions]; @@ -453,7 +458,11 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl [launchOptions setObject:[url absoluteString] forKey:@"url"]; [launchOptions removeObjectForKey:UIApplicationLaunchOptionsSourceApplicationKey]; - [launchOptions setObject:sourceApplication ?: [NSNull null] forKey:@"source"]; + if (sourceApplication != nil) { + [launchOptions setObject:sourceApplication forKey:@"source"]; + } else { + [launchOptions removeObjectForKey:@"source"]; + } if (appBooted) { [[NSNotificationCenter defaultCenter] postNotificationName:kTiApplicationLaunchedFromURL object:self userInfo:launchOptions]; @@ -1376,7 +1385,7 @@ + (NSDictionary *)dictionaryWithUserNotification:(UNNotification *)notification [event setObject:NULL_IF_NIL(notification.request.content.userInfo) forKey:@"userInfo"]; [event setObject:NULL_IF_NIL(notification.request.content.categoryIdentifier) forKey:@"category"]; [event setObject:NULL_IF_NIL(notification.request.content.threadIdentifier) forKey:@"threadIdentifier"]; - [event setObject:NULL_IF_NIL(notification.request.identifier) forKey:@"identifier"]; + [event setObject:NULL_IF_NIL(identifier) forKey:@"identifier"]; // iOS 10+ does have "soundName" but "sound" which is a native object. But if we find // a sound in the APS dictionary, we can provide that one for parity diff --git a/iphone/TitaniumKit/TitaniumKit/Sources/API/TiBase.h b/iphone/TitaniumKit/TitaniumKit/Sources/API/TiBase.h index e2af765dee5..450c27793bf 100644 --- a/iphone/TitaniumKit/TitaniumKit/Sources/API/TiBase.h +++ b/iphone/TitaniumKit/TitaniumKit/Sources/API/TiBase.h @@ -129,6 +129,24 @@ NSString *JavascriptNameForClass(Class c); #define NULL_IF_NIL(x) ({ id xx = (x); (xx==nil)?[NSNull null]:xx; }) +#define IS_NULL_OR_NIL(x) ((x == nil) || ((id)x == [NSNull null])) + +#define ENSURE_CLASS_OR_NIL(x, t) \ + if (IS_NULL_OR_NIL(x)) { \ + x = nil; \ + } else if (![x isKindOfClass:t]) { \ + [self throwException:TiExceptionInvalidType subreason:[NSString stringWithFormat:@"expected: %@ or nil, was: %@", CLASS2JS(t), OBJTYPE2JS(x)] location:CODELOCATION]; \ + } + +#define ENSURE_TYPE_OR_NIL(x, t) ENSURE_CLASS_OR_NIL(x, [t class]) + +#define ENSURE_CLASS(x, t) \ + if (![x isKindOfClass:t]) { \ + [self throwException:TiExceptionInvalidType subreason:[NSString stringWithFormat:@"expected: %@, was: %@", CLASS2JS(t), OBJTYPE2JS(x)] location:CODELOCATION]; \ + } + +#define ENSURE_TYPE(x, t) ENSURE_CLASS(x, [t class]) + //NOTE: these checks can be pulled out of production build type //Question: Given that some of these silently massage the data during development but not production, @@ -141,40 +159,31 @@ NSString *JavascriptNameForClass(Class c); ENSURE_TYPE_OR_NIL(x, NSString); \ } -#define ENSURE_SINGLE_ARG(x, t) \ - if ([x isKindOfClass:[NSArray class]] && [x count] > 0) { \ - x = (t *)[x objectAtIndex:0]; \ - } \ - if (![x isKindOfClass:[t class]]) { \ - [self throwException:TiExceptionInvalidType subreason:[NSString stringWithFormat:@"expected: %@, was: %@", CLASS2JS([t class]), OBJTYPE2JS(x)] location:CODELOCATION]; \ - } +#define ENSURE_SINGLE_ARG(x, t) \ + if ([x isKindOfClass:[NSArray class]] && [(NSArray *)x count] > 0) { \ + x = (t *)[x objectAtIndex:0]; \ + } \ + ENSURE_TYPE(x, t); -#define ENSURE_SINGLE_ARG_OR_NIL(x, t) \ - if (x == nil || x == [NSNull null]) { \ - x = nil; \ - } else { \ - if ([x isKindOfClass:[NSArray class]] && [x count] > 0) { \ - x = (t *)[x objectAtIndex:0]; \ - } \ - if (![x isKindOfClass:[t class]]) { \ - [self throwException:TiExceptionInvalidType subreason:[NSString stringWithFormat:@"expected: %@, was: %@", CLASS2JS([t class]), OBJTYPE2JS(x)] location:CODELOCATION]; \ - } \ +#define ENSURE_SINGLE_ARG_OR_NIL(x, t) \ + if (IS_NULL_OR_NIL(x)) { \ + x = nil; \ + } else { \ + ENSURE_SINGLE_ARG(x, t); \ } -#define ENSURE_ARG_AT_INDEX(out, args, index, type) \ - if ([args isKindOfClass:[NSArray class]] && [args count] > index) { \ - out = (type *)[args objectAtIndex:index]; \ - } \ - if (![out isKindOfClass:[type class]]) { \ - [self throwException:TiExceptionInvalidType subreason:[NSString stringWithFormat:@"expected: %@, was: %@", CLASS2JS([type class]), OBJTYPE2JS(out)] location:CODELOCATION]; \ - } +#define ENSURE_ARG_AT_INDEX(out, args, index, type) \ + if ([args isKindOfClass:[NSArray class]] && [(NSArray *)args count] > index) { \ + out = (type *)[(NSArray *)args objectAtIndex:index]; \ + } \ + ENSURE_TYPE(out, type); #define ENSURE_ARG_OR_NIL_AT_INDEX(out, args, index, type) \ - if (args == nil || args == [NSNull null]) { \ + if (IS_NULL_OR_NIL(args)) { \ out = nil; \ } else if ([args isKindOfClass:[NSArray class]]) { \ - if ([args count] > index) { \ - out = [args objectAtIndex:index]; \ + if ([(NSArray *)args count] > index) { \ + out = [(NSArray *)args objectAtIndex:index]; \ } else { \ out = nil; \ } \ @@ -239,30 +248,12 @@ NSString *JavascriptNameForClass(Class c); } \ } -#define ENSURE_CLASS(x, t) \ - if (![x isKindOfClass:t]) { \ - [self throwException:TiExceptionInvalidType subreason:[NSString stringWithFormat:@"expected: %@, was: %@", CLASS2JS(t), OBJTYPE2JS(x)] location:CODELOCATION]; \ - } - -#define ENSURE_TYPE(x, t) ENSURE_CLASS(x, [t class]) - //Because both NSString and NSNumber respond to intValue, etc, this is a wider net #define ENSURE_METHOD(x, t) \ if (![x respondsToSelector:@selector(t)]) { \ [self throwException:TiExceptionInvalidType subreason:[NSString stringWithFormat:@"%@ doesn't respond to method: %@", OBJTYPE2JS(x), @ #t] location:CODELOCATION]; \ } -#define IS_NULL_OR_NIL(x) ((x == nil) || ((id)x == [NSNull null])) - -#define ENSURE_CLASS_OR_NIL(x, t) \ - if (IS_NULL_OR_NIL(x)) { \ - x = nil; \ - } else if (![x isKindOfClass:t]) { \ - [self throwException:TiExceptionInvalidType subreason:[NSString stringWithFormat:@"expected: %@ or nil, was: %@", CLASS2JS(t), OBJTYPE2JS(x)] location:CODELOCATION]; \ - } - -#define ENSURE_TYPE_OR_NIL(x, t) ENSURE_CLASS_OR_NIL(x, [t class]) - #define ENSURE_ARG_COUNT(x, c) \ if ([x count] < c) { \ [self throwException:TiExceptionNotEnoughArguments subreason:[NSString stringWithFormat:@"expected %d arguments, received: %lu", c, (unsigned long)[x count]] location:CODELOCATION]; \ diff --git a/iphone/TitaniumKit/TitaniumKit/Sources/Modules/TiUIWindowProxy.m b/iphone/TitaniumKit/TitaniumKit/Sources/Modules/TiUIWindowProxy.m index 502e9c0df05..1840eda67c3 100644 --- a/iphone/TitaniumKit/TitaniumKit/Sources/Modules/TiUIWindowProxy.m +++ b/iphone/TitaniumKit/TitaniumKit/Sources/Modules/TiUIWindowProxy.m @@ -455,11 +455,23 @@ - (void)updateBarImage if (theImage != nil) { UIImage *resizableImage = [theImage resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0) resizingMode:UIImageResizingModeStretch]; ourNB.shadowImage = resizableImage; +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 + if ([TiUtils isIOSVersionOrGreater:@"13.0"]) { + ourNB.standardAppearance.shadowImage = resizableImage; + ourNB.scrollEdgeAppearance.shadowImage = resizableImage; + } +#endif } else { BOOL clipValue = [TiUtils boolValue:[self valueForUndefinedKey:@"hideShadow"] def:NO]; if (clipValue) { //Set an empty Image. ourNB.shadowImage = [[[UIImage alloc] init] autorelease]; +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 + if ([TiUtils isIOSVersionOrGreater:@"13.0"]) { + ourNB.standardAppearance.shadowColor = nil; + ourNB.scrollEdgeAppearance.shadowColor = nil; + } +#endif } else { ourNB.shadowImage = nil; }