From cd39dabaa574db6f934905f42bc76e9f5c6b2547 Mon Sep 17 00:00:00 2001 From: emawby Date: Mon, 10 Jul 2023 14:28:55 -0700 Subject: [PATCH] Removing launchURLsInApp and webkit code from Notifications We are removing the launch push notification urls in a webview feature. This feature was not consistently effective, and added a webkit dependency to notifications that has gotten apps rejected from the app store. If we later want to add this feature back we should consider it as an optional module. --- .../OneSignalDevApp/AppDelegate.m | 1 - .../OneSignalDevAppClip/AppDelegate.m | 1 - .../OneSignal.xcodeproj/project.pbxproj | 32 +++++++----------- .../Source/OneSignalCommonDefines.h | 1 - .../UI/OneSignalWebView.h | 0 .../UI/OneSignalWebView.m | 0 .../UI/OneSignalWebViewManager.h | 2 +- .../UI/OneSignalWebViewManager.m | 0 .../OSNotificationsManager.m | 17 ++-------- .../OneSignalNotifications.h | 2 -- iOS_SDK/OneSignalSDK/Source/OneSignal.m | 33 ------------------- .../OneSignalSDK/Source/OneSignalFramework.h | 1 - iOS_SDK/OneSignalSDK/Source/OneSignalHelper.h | 1 - iOS_SDK/OneSignalSDK/Source/OneSignalHelper.m | 28 ++-------------- iOS_SDK/OneSignalSDK/UnitTests/UnitTests.m | 16 --------- 15 files changed, 18 insertions(+), 117 deletions(-) rename iOS_SDK/OneSignalSDK/{OneSignalNotifications => OneSignalInAppMessages}/UI/OneSignalWebView.h (100%) rename iOS_SDK/OneSignalSDK/{OneSignalNotifications => OneSignalInAppMessages}/UI/OneSignalWebView.m (100%) rename iOS_SDK/OneSignalSDK/{OneSignalNotifications => OneSignalInAppMessages}/UI/OneSignalWebViewManager.h (96%) rename iOS_SDK/OneSignalSDK/{OneSignalNotifications => OneSignalInAppMessages}/UI/OneSignalWebViewManager.m (100%) diff --git a/iOS_SDK/OneSignalDevApp/OneSignalDevApp/AppDelegate.m b/iOS_SDK/OneSignalDevApp/OneSignalDevApp/AppDelegate.m index da5664ba5..44c516b10 100644 --- a/iOS_SDK/OneSignalDevApp/OneSignalDevApp/AppDelegate.m +++ b/iOS_SDK/OneSignalDevApp/OneSignalDevApp/AppDelegate.m @@ -58,7 +58,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( _notificationDelegate = [OneSignalNotificationCenterDelegate new]; // OneSignal Init with app id and lauch options - [OneSignal setLaunchURLsInApp:YES]; [OneSignal setProvidesNotificationSettingsView:NO]; [OneSignal.InAppMessages addLifecycleListener:self]; diff --git a/iOS_SDK/OneSignalDevApp/OneSignalDevAppClip/AppDelegate.m b/iOS_SDK/OneSignalDevApp/OneSignalDevAppClip/AppDelegate.m index 7e11a86c5..915298410 100644 --- a/iOS_SDK/OneSignalDevApp/OneSignalDevAppClip/AppDelegate.m +++ b/iOS_SDK/OneSignalDevApp/OneSignalDevAppClip/AppDelegate.m @@ -56,7 +56,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( _notificationDelegate = [OneSignalNotificationCenterDelegate new]; // OneSignal Init with app id and lauch options - [OneSignal setLaunchURLsInApp:YES]; [OneSignal setProvidesNotificationSettingsView:NO]; [OneSignal initialize:[AppDelegate getOneSignalAppId] withLaunchOptions:launchOptions]; diff --git a/iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj b/iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj index 4bf280e2c..d0c7829d5 100644 --- a/iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj +++ b/iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj @@ -243,6 +243,10 @@ DE69E1A0282ED8060090BB3D /* OneSignalUser.h in Headers */ = {isa = PBXBuildFile; fileRef = DE69E19D282ED8060090BB3D /* OneSignalUser.h */; settings = {ATTRIBUTES = (Public, ); }; }; DE69E1AC282ED87A0090BB3D /* OneSignalUserManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE69E1AA282ED8790090BB3D /* OneSignalUserManagerImpl.swift */; }; DE69E1B2282ED9430090BB3D /* OneSignalUser.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DE69E19B282ED8060090BB3D /* OneSignalUser.framework */; }; + DE70EB922A5CACF5003166D3 /* OneSignalWebViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = DEF7847F29146BBE00A1F3A5 /* OneSignalWebViewManager.m */; }; + DE70EB932A5CACF5003166D3 /* OneSignalWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = DEF7847B29146B2700A1F3A5 /* OneSignalWebView.m */; }; + DE70EB942A5CAD70003166D3 /* OneSignalWebView.h in Headers */ = {isa = PBXBuildFile; fileRef = DEF7847C29146B2700A1F3A5 /* OneSignalWebView.h */; }; + DE70EB952A5CAD77003166D3 /* OneSignalWebViewManager.h in Headers */ = {isa = PBXBuildFile; fileRef = DEF7848129146BD100A1F3A5 /* OneSignalWebViewManager.h */; }; DE7D17EA27026B95002D3A5D /* OneSignalCore.docc in Sources */ = {isa = PBXBuildFile; fileRef = DE7D17E927026B95002D3A5D /* OneSignalCore.docc */; }; DE7D17EB27026B95002D3A5D /* OneSignalCore.h in Headers */ = {isa = PBXBuildFile; fileRef = DE7D17E827026B95002D3A5D /* OneSignalCore.h */; settings = {ATTRIBUTES = (Public, ); }; }; DE7D17FD27026BA3002D3A5D /* OneSignalExtension.docc in Sources */ = {isa = PBXBuildFile; fileRef = DE7D17FC27026BA3002D3A5D /* OneSignalExtension.docc */; }; @@ -454,10 +458,6 @@ DEF7847229132AA700A1F3A5 /* OSNotification+OneSignal.h in Headers */ = {isa = PBXBuildFile; fileRef = DEF7847029132AA700A1F3A5 /* OSNotification+OneSignal.h */; settings = {ATTRIBUTES = (Public, ); }; }; DEF7847329132AA700A1F3A5 /* OSNotification+OneSignal.m in Sources */ = {isa = PBXBuildFile; fileRef = DEF7847129132AA700A1F3A5 /* OSNotification+OneSignal.m */; }; DEF784792914667A00A1F3A5 /* NSDateFormatter+OneSignal.h in Headers */ = {isa = PBXBuildFile; fileRef = DE9877292591654600DE07D5 /* NSDateFormatter+OneSignal.h */; settings = {ATTRIBUTES = (Public, ); }; }; - DEF7847D29146B2700A1F3A5 /* OneSignalWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = DEF7847B29146B2700A1F3A5 /* OneSignalWebView.m */; }; - DEF7847E29146B2700A1F3A5 /* OneSignalWebView.h in Headers */ = {isa = PBXBuildFile; fileRef = DEF7847C29146B2700A1F3A5 /* OneSignalWebView.h */; settings = {ATTRIBUTES = (Public, ); }; }; - DEF7848029146BBE00A1F3A5 /* OneSignalWebViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = DEF7847F29146BBE00A1F3A5 /* OneSignalWebViewManager.m */; }; - DEF7848229146BD100A1F3A5 /* OneSignalWebViewManager.h in Headers */ = {isa = PBXBuildFile; fileRef = DEF7848129146BD100A1F3A5 /* OneSignalWebViewManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; DEF7848429146DA700A1F3A5 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DEF7848329146DA700A1F3A5 /* WebKit.framework */; }; DEF7848A291471DA00A1F3A5 /* UNUserNotificationCenter+OneSignalNotifications.m in Sources */ = {isa = PBXBuildFile; fileRef = DEF78486291471D900A1F3A5 /* UNUserNotificationCenter+OneSignalNotifications.m */; }; DEF7848B291471DA00A1F3A5 /* UIApplicationDelegate+OneSignalNotifications.h in Headers */ = {isa = PBXBuildFile; fileRef = DEF78487291471DA00A1F3A5 /* UIApplicationDelegate+OneSignalNotifications.h */; }; @@ -1936,6 +1936,10 @@ DEBAAE4C2A42157B00BF2C1C /* UI */ = { isa = PBXGroup; children = ( + DEF7847C29146B2700A1F3A5 /* OneSignalWebView.h */, + DEF7847B29146B2700A1F3A5 /* OneSignalWebView.m */, + DEF7848129146BD100A1F3A5 /* OneSignalWebViewManager.h */, + DEF7847F29146BBE00A1F3A5 /* OneSignalWebViewManager.m */, DEBAAE512A42174A00BF2C1C /* OSInAppMessageView.h */, DEBAAE532A42174A00BF2C1C /* OSInAppMessageView.m */, DEBAAE522A42174A00BF2C1C /* OSInAppMessageViewController.h */, @@ -2020,7 +2024,6 @@ children = ( DEF7842B2912DEBA00A1F3A5 /* OneSignalNotifications.h */, DEF78485291471B200A1F3A5 /* Categories */, - DEF7847A29146B0B00A1F3A5 /* UI */, DEF7844B2912E35700A1F3A5 /* NotificationSettings */, DEF784482912E23A00A1F3A5 /* OSNotificationsManager.h */, DEF784472912E23A00A1F3A5 /* OSNotificationsManager.m */, @@ -2049,17 +2052,6 @@ path = NotificationSettings; sourceTree = ""; }; - DEF7847A29146B0B00A1F3A5 /* UI */ = { - isa = PBXGroup; - children = ( - DEF7847C29146B2700A1F3A5 /* OneSignalWebView.h */, - DEF7847B29146B2700A1F3A5 /* OneSignalWebView.m */, - DEF7848129146BD100A1F3A5 /* OneSignalWebViewManager.h */, - DEF7847F29146BBE00A1F3A5 /* OneSignalWebViewManager.m */, - ); - path = UI; - sourceTree = ""; - }; DEF78485291471B200A1F3A5 /* Categories */ = { isa = PBXGroup; children = ( @@ -2241,8 +2233,10 @@ DEBAAE7E2A42176800BF2C1C /* OSInAppMessageDisplayStats.h in Headers */, DEBAAE882A42176800BF2C1C /* OSInAppMessageClickEvent.h in Headers */, DEBAAE7D2A42176800BF2C1C /* OSInAppMessagePage.h in Headers */, + DE70EB952A5CAD77003166D3 /* OneSignalWebViewManager.h in Headers */, DEBAAE8B2A42176800BF2C1C /* OSInAppMessageClickResult.h in Headers */, DEBAAE912A42176800BF2C1C /* OSInAppMessagePushPrompt.h in Headers */, + DE70EB942A5CAD70003166D3 /* OneSignalWebView.h in Headers */, DEBAAE2B2A4211DA00BF2C1C /* OneSignalInAppMessages.h in Headers */, DEBAAE8D2A42176800BF2C1C /* OSInAppMessageBridgeEvent.h in Headers */, ); @@ -2254,13 +2248,11 @@ files = ( DEF7842C2912DEBA00A1F3A5 /* OneSignalNotifications.h in Headers */, DEF784522912E3EB00A1F3A5 /* OneSignalNotificationSettings.h in Headers */, - DEF7848229146BD100A1F3A5 /* OneSignalWebViewManager.h in Headers */, DEF7848C291471DA00A1F3A5 /* UNUserNotificationCenter+OneSignalNotifications.h in Headers */, DEF7847229132AA700A1F3A5 /* OSNotification+OneSignal.h in Headers */, DEF784582912E4BA00A1F3A5 /* OSPermission.h in Headers */, DEF7848B291471DA00A1F3A5 /* UIApplicationDelegate+OneSignalNotifications.h in Headers */, DEF7844A2912E23A00A1F3A5 /* OSNotificationsManager.h in Headers */, - DEF7847E29146B2700A1F3A5 /* OneSignalWebView.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3035,9 +3027,11 @@ DEBAAE812A42176800BF2C1C /* OSTrigger.m in Sources */, DEBAAE832A42176800BF2C1C /* OSInAppMessageLocationPrompt.m in Sources */, DEBAAE952A42177B00BF2C1C /* OSInAppMessagingRequests.m in Sources */, + DE70EB922A5CACF5003166D3 /* OneSignalWebViewManager.m in Sources */, DEBAAE992A42179A00BF2C1C /* OneSignalInAppMessages.m in Sources */, DEBAAE602A42175A00BF2C1C /* OSDynamicTriggerController.m in Sources */, DEBAAE8A2A42176800BF2C1C /* OSInAppMessageInternal.m in Sources */, + DE70EB932A5CACF5003166D3 /* OneSignalWebView.m in Sources */, DEBAAE872A42176800BF2C1C /* OSInAppMessageBridgeEvent.m in Sources */, DEBAAE892A42176800BF2C1C /* OSInAppMessageClickEvent.m in Sources */, DEBAAE842A42176800BF2C1C /* OSInAppMessageDisplayStats.m in Sources */, @@ -3063,13 +3057,11 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - DEF7848029146BBE00A1F3A5 /* OneSignalWebViewManager.m in Sources */, DEF784592912E4BA00A1F3A5 /* OSPermission.m in Sources */, DEF7847329132AA700A1F3A5 /* OSNotification+OneSignal.m in Sources */, DEF784492912E23A00A1F3A5 /* OSNotificationsManager.m in Sources */, DEF7848D291471DA00A1F3A5 /* UIApplicationDelegate+OneSignalNotifications.m in Sources */, DEF784552912E3EB00A1F3A5 /* OneSignalNotificationSettings.m in Sources */, - DEF7847D29146B2700A1F3A5 /* OneSignalWebView.m in Sources */, DEF7848A291471DA00A1F3A5 /* UNUserNotificationCenter+OneSignalNotifications.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalCommonDefines.h b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalCommonDefines.h index 1c8d2fb0a..eacf81b2c 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalCommonDefines.h +++ b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalCommonDefines.h @@ -73,7 +73,6 @@ // Notification #define OSUD_LAST_MESSAGE_OPENED @"GT_LAST_MESSAGE_OPENED_" // * OSUD_MOST_RECENT_NOTIFICATION_OPENED -#define OSUD_NOTIFICATION_OPEN_LAUNCH_URL @"ONESIGNAL_INAPP_LAUNCH_URL" // * OSUD_NOTIFICATION_OPEN_LAUNCH_URL #define OSUD_TEMP_CACHED_NOTIFICATION_MEDIA @"OSUD_TEMP_CACHED_NOTIFICATION_MEDIA" // OSUD_TEMP_CACHED_NOTIFICATION_MEDIA // Remote Params #define OSUD_LOCATION_ENABLED @"OSUD_LOCATION_ENABLED" diff --git a/iOS_SDK/OneSignalSDK/OneSignalNotifications/UI/OneSignalWebView.h b/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/UI/OneSignalWebView.h similarity index 100% rename from iOS_SDK/OneSignalSDK/OneSignalNotifications/UI/OneSignalWebView.h rename to iOS_SDK/OneSignalSDK/OneSignalInAppMessages/UI/OneSignalWebView.h diff --git a/iOS_SDK/OneSignalSDK/OneSignalNotifications/UI/OneSignalWebView.m b/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/UI/OneSignalWebView.m similarity index 100% rename from iOS_SDK/OneSignalSDK/OneSignalNotifications/UI/OneSignalWebView.m rename to iOS_SDK/OneSignalSDK/OneSignalInAppMessages/UI/OneSignalWebView.m diff --git a/iOS_SDK/OneSignalSDK/OneSignalNotifications/UI/OneSignalWebViewManager.h b/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/UI/OneSignalWebViewManager.h similarity index 96% rename from iOS_SDK/OneSignalSDK/OneSignalNotifications/UI/OneSignalWebViewManager.h rename to iOS_SDK/OneSignalSDK/OneSignalInAppMessages/UI/OneSignalWebViewManager.h index add4923cb..ec0bb71cf 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalNotifications/UI/OneSignalWebViewManager.h +++ b/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/UI/OneSignalWebViewManager.h @@ -25,7 +25,7 @@ THE SOFTWARE. */ -#import +#import "OneSignalWebView.h" @interface OneSignalWebViewManager : NSObject + (OneSignalWebView *_Nonnull)webVC; diff --git a/iOS_SDK/OneSignalSDK/OneSignalNotifications/UI/OneSignalWebViewManager.m b/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/UI/OneSignalWebViewManager.m similarity index 100% rename from iOS_SDK/OneSignalSDK/OneSignalNotifications/UI/OneSignalWebViewManager.m rename to iOS_SDK/OneSignalSDK/OneSignalInAppMessages/UI/OneSignalWebViewManager.m diff --git a/iOS_SDK/OneSignalSDK/OneSignalNotifications/OSNotificationsManager.m b/iOS_SDK/OneSignalSDK/OneSignalNotifications/OSNotificationsManager.m index c83f3e586..c158dcc5c 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalNotifications/OSNotificationsManager.m +++ b/iOS_SDK/OneSignalSDK/OneSignalNotifications/OSNotificationsManager.m @@ -735,27 +735,14 @@ + (void)launchWebURL:(NSString*)openUrl { } + (void)displayWebView:(NSURL*)url { - // Check if in-app or safari - __block BOOL inAppLaunch = [OneSignalUserDefaults.initStandard getSavedBoolForKey:OSUD_NOTIFICATION_OPEN_LAUNCH_URL defaultValue:false]; - - // If the URL contains itunes.apple.com, it's an app store link - // that should be opened using sharedApplication openURL - if ([[url absoluteString] rangeOfString:@"itunes.apple.com"].location != NSNotFound) { - inAppLaunch = NO; - } - __block let openUrlBlock = ^void(BOOL shouldOpen) { if (!shouldOpen) return; [OneSignalCoreHelper dispatch_async_on_main_queue: ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - if (inAppLaunch && [OneSignalCoreHelper isWWWScheme:url]) { - [OneSignalWebViewManager displayWebView: url]; - } else { - // Keep dispatch_async. Without this the url can take an extra 2 to 10 secounds to open. - [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; - } + // Keep dispatch_async. Without this the url can take an extra 2 to 10 secounds to open. + [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; }); }]; }; diff --git a/iOS_SDK/OneSignalSDK/OneSignalNotifications/OneSignalNotifications.h b/iOS_SDK/OneSignalSDK/OneSignalNotifications/OneSignalNotifications.h index e55d3b809..4e0368d99 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalNotifications/OneSignalNotifications.h +++ b/iOS_SDK/OneSignalSDK/OneSignalNotifications/OneSignalNotifications.h @@ -29,6 +29,4 @@ #import #import -#import -#import #import diff --git a/iOS_SDK/OneSignalSDK/Source/OneSignal.m b/iOS_SDK/OneSignalSDK/Source/OneSignal.m index 653f6edab..690215bd6 100755 --- a/iOS_SDK/OneSignalSDK/Source/OneSignal.m +++ b/iOS_SDK/OneSignalSDK/Source/OneSignal.m @@ -77,9 +77,6 @@ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" -/* Enable the default in-app launch urls*/ -NSString* const kOSSettingsKeyInAppLaunchURL = @"kOSSettingsKeyInAppLaunchURL"; - /* Omit no appId error logging, for use with wrapper SDKs. */ NSString* const kOSSettingsKeyInOmitNoAppIdLogging = @"kOSSettingsKeyInOmitNoAppIdLogging"; @@ -335,15 +332,6 @@ + (void)setLaunchOptions:(nullable NSDictionary*)newLaunchOptions { [OSNotificationsManager setColdStartFromTapOnNotification:YES]; } -// TODO: Should this be in the InAppMessages namespace? -+ (void)setLaunchURLsInApp:(BOOL)launchInApp { - NSMutableDictionary *newSettings = [[NSMutableDictionary alloc] initWithDictionary:appSettings]; - newSettings[kOSSettingsKeyInAppLaunchURL] = launchInApp ? @true : @false; - appSettings = newSettings; - // This allows this method to have an effect after init is called - [self enableInAppLaunchURL:launchInApp]; -} - + (void)setProvidesNotificationSettingsView:(BOOL)providesView { if (providesView && [OSDeviceUtils isIOSVersionGreaterThanOrEqual:@"12.0"]) { [OSNotificationsManager setProvidesNotificationSettingsView: providesView]; @@ -441,21 +429,6 @@ + (void)startNewSessionInternal { // [OSMessagingController.sharedInstance updateInAppMessagesFromCache]; // go to controller } -+ (void)initInAppLaunchURLSettings:(NSDictionary*)settings { - // TODO: Make booleans on the class instead of as keys in a dictionary - let standardUserDefaults = OneSignalUserDefaults.initStandard; - // Check if disabled in-app launch url if passed a NO - if (settings[kOSSettingsKeyInAppLaunchURL] && [settings[kOSSettingsKeyInAppLaunchURL] isKindOfClass:[NSNumber class]]) - - [self enableInAppLaunchURL:[settings[kOSSettingsKeyInAppLaunchURL] boolValue]]; - - else if (![standardUserDefaults keyExists:OSUD_NOTIFICATION_OPEN_LAUNCH_URL]) { - // Only need to default to true if the app doesn't already have this setting saved in NSUserDefaults - - [self enableInAppLaunchURL:true]; - } -} - + (void)startInAppMessages { let oneSignalInAppMessages = NSClassFromString(@"OneSignalInAppMessages"); if (oneSignalInAppMessages != nil && [oneSignalInAppMessages respondsToSelector:@selector(start)]) { @@ -536,8 +509,6 @@ + (void)init { // Now really initializing the SDK! - [self initInAppLaunchURLSettings:appSettings]; - // Invalid app ids reaching here will cause failure if (![self isValidAppId:appId]) return; @@ -690,10 +661,6 @@ + (void)downloadIOSParamsWithAppId:(NSString *)appId { }]; } -+ (void)enableInAppLaunchURL:(BOOL)enable { - [OneSignalUserDefaults.initStandard saveBoolForKey:OSUD_NOTIFICATION_OPEN_LAUNCH_URL withValue:enable]; -} - //TODO: consolidate in one place. Where??? + (void)launchWebURL:(NSString*)openUrl { diff --git a/iOS_SDK/OneSignalSDK/Source/OneSignalFramework.h b/iOS_SDK/OneSignalSDK/Source/OneSignalFramework.h index 23a07625f..d304b4ba6 100755 --- a/iOS_SDK/OneSignalSDK/Source/OneSignalFramework.h +++ b/iOS_SDK/OneSignalSDK/Source/OneSignalFramework.h @@ -80,7 +80,6 @@ NS_SWIFT_NAME(login(externalId:token:)); #pragma mark Initialization + (void)setLaunchOptions:(nullable NSDictionary*)newLaunchOptions; // meant for use by wrappers + (void)initialize:(nonnull NSString*)newAppId withLaunchOptions:(nullable NSDictionary*)launchOptions; -+ (void)setLaunchURLsInApp:(BOOL)launchInApp; + (void)setProvidesNotificationSettingsView:(BOOL)providesView; #pragma mark Live Activity diff --git a/iOS_SDK/OneSignalSDK/Source/OneSignalHelper.h b/iOS_SDK/OneSignalSDK/Source/OneSignalHelper.h index 5be010a94..86c1e05ce 100644 --- a/iOS_SDK/OneSignalSDK/Source/OneSignalHelper.h +++ b/iOS_SDK/OneSignalSDK/Source/OneSignalHelper.h @@ -34,7 +34,6 @@ @interface OneSignalHelper : NSObject // - Web -+ (OneSignalWebView*)webVC; + (void) displayWebView:(NSURL*)url; // Threading diff --git a/iOS_SDK/OneSignalSDK/Source/OneSignalHelper.m b/iOS_SDK/OneSignalSDK/Source/OneSignalHelper.m index 2d331d220..c7848b99d 100644 --- a/iOS_SDK/OneSignalSDK/Source/OneSignalHelper.m +++ b/iOS_SDK/OneSignalSDK/Source/OneSignalHelper.m @@ -53,12 +53,6 @@ + (NSString*)mUserId; @implementation OneSignalHelper -//Passed to the OnFocus to make sure dismissed when coming back into app -OneSignalWebView *webVC; -+ (OneSignalWebView*)webVC { - return webVC; -} - + (NSString*)getAppName { return [[[NSBundle mainBundle] infoDictionary] objectForKey:(id)kCFBundleNameKey]; } @@ -73,31 +67,15 @@ + (OneSignal*)sharedInstance { return singleInstance; } -+ (void)displayWebView:(NSURL*)url { - // Check if in-app or safari - __block BOOL inAppLaunch = [OneSignalUserDefaults.initStandard getSavedBoolForKey:OSUD_NOTIFICATION_OPEN_LAUNCH_URL defaultValue:false]; - - // If the URL contains itunes.apple.com, it's an app store link - // that should be opened using sharedApplication openURL - if ([[url absoluteString] rangeOfString:@"itunes.apple.com"].location != NSNotFound) { - inAppLaunch = NO; - } - ++ (void)displayWebView:(NSURL*)url { __block let openUrlBlock = ^void(BOOL shouldOpen) { if (!shouldOpen) return; [OneSignalHelper dispatch_async_on_main_queue: ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - if (inAppLaunch && [OneSignalCoreHelper isWWWScheme:url]) { - if (!webVC) - webVC = [[OneSignalWebView alloc] init]; - webVC.url = url; - [webVC showInApp]; - } else { - // Keep dispatch_async. Without this the url can take an extra 2 to 10 secounds to open. - [[UIApplication sharedApplication] openURL:url]; - } + // Keep dispatch_async. Without this the url can take an extra 2 to 10 secounds to open. + [[UIApplication sharedApplication] openURL:url]; }); }]; }; diff --git a/iOS_SDK/OneSignalSDK/UnitTests/UnitTests.m b/iOS_SDK/OneSignalSDK/UnitTests/UnitTests.m index 69626b6ed..2c49fe687 100644 --- a/iOS_SDK/OneSignalSDK/UnitTests/UnitTests.m +++ b/iOS_SDK/OneSignalSDK/UnitTests/UnitTests.m @@ -3349,22 +3349,6 @@ - (void)testLaunchURL { XCTAssertFalse(OneSignalOverrider.launchWebURLWasCalled); } -- (void)testsetLaunchURLInAppAfterInit { - // 1. setLaunchURLsInApp to false - [OneSignal setLaunchURLsInApp:false]; - - // 2. Init OneSignal with app start - [UnitTestCommonMethods initOneSignal]; - [UnitTestCommonMethods runBackgroundThreads]; - - XCTAssertFalse([OneSignalUserDefaults.initStandard getSavedBoolForKey:OSUD_NOTIFICATION_OPEN_LAUNCH_URL defaultValue:false]); - - // 3. Change setLaunchURLsInApp to true - [OneSignal setLaunchURLsInApp:true]; - - XCTAssertTrue([OneSignalUserDefaults.initStandard getSavedBoolForKey:OSUD_NOTIFICATION_OPEN_LAUNCH_URL defaultValue:false]); -} - - (void)testTimezoneId { let mockTimezone = [NSTimeZone timeZoneWithName:@"Europe/London"];