Skip to content

Commit e1d1b6e

Browse files
author
Joseph Kalash
committed
- Fixed an issue where receiving two notifications with launchURLs would launch multiple webviews without dismissing currently open ones.
- Updated device registration login. OneSignal will now wait a few seconds to try to get a device token before registering with OneSignal. This prevents some cases where devices could be duplicated on the OneSignal dashboard when previous device data was imported.
1 parent 97219a1 commit e1d1b6e

File tree

6 files changed

+19
-11
lines changed

6 files changed

+19
-11
lines changed

OneSignal.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "OneSignal"
3-
s.version = "2.1.1"
3+
s.version = "2.1.2"
44
s.summary = "OneSignal push notification library for mobile apps."
55
s.homepage = "https://onesignal.com"
66
s.license = { :type => 'MIT', :file => 'LICENSE' }
7.91 KB
Binary file not shown.
7.68 KB
Binary file not shown.

iOS_SDK/OneSignal/OneSignal.m

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171

7272
@implementation OneSignal
7373

74-
NSString* const ONESIGNAL_VERSION = @"020101";
74+
NSString* const ONESIGNAL_VERSION = @"020102";
7575
static NSString* mSDKType = @"native";
7676
static BOOL coldStartFromTapOnNotification = NO;
7777
static BOOL registeredWithApple = NO; //Has attempted to register for push notifications with Apple.
@@ -186,6 +186,11 @@ + (id)initWithLaunchOptions:(NSDictionary*)launchOptions appId:(NSString*)appId
186186
else if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerForRemoteNotifications)])
187187
[[UIApplication sharedApplication] registerForRemoteNotifications];
188188

189+
if (mUserId != nil)
190+
[self registerUser];
191+
else // Fall back incase Apple does not responsed in time.
192+
[self performSelector:@selector(registerUser) withObject:nil afterDelay:30.0f];
193+
189194
[OneSignalTracker onFocus:NO];
190195
}
191196

@@ -506,12 +511,12 @@ + (void)updateDeviceToken:(NSString*)deviceToken onSuccess:(OSResultSuccessBlock
506511
tokenUpdateSuccessBlock = successBlock;
507512
tokenUpdateFailureBlock = failureBlock;
508513

509-
// iOS 8 - We get a token right away but give the user 10 sec to responsed to the system prompt.
514+
// iOS 8 - We get a token right away but give the user 30 sec to responsed to the system prompt.
510515
// Also check mNotificationTypes so there is no waiting if user has already answered the system prompt.
511516
// The goal is to only have 1 server call.
512517
if ([OneSignalHelper isCapableOfGettingNotificationTypes] && mNotificationTypes == -1) {
513518
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(registerUser) object:nil];
514-
[self performSelector:@selector(registerUser) withObject:nil afterDelay:10.0f];
519+
[self performSelector:@selector(registerUser) withObject:nil afterDelay:30.0f];
515520
}
516521
else
517522
[OneSignal registerUser];

iOS_SDK/OneSignalTracker.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ + (void)onFocus:(BOOL)toBackground {
7474
lastOpenedTime = now;
7575
[OneSignal sendNotificationTypesUpdate:false];
7676
wasBadgeSet = [OneSignal clearBadgeCount:false];
77-
[OneSignal registerUser];
7877

7978
//Make sure webview dismissed if came back from deep link
8079
OneSignalWebView *webVC = [OneSignalHelper webVC];

iOS_SDK/OneSignalWebView.m

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,19 @@ -(void)showInApp {
9898
}
9999

100100
UIWindow* mainWindow = [[UIApplication sharedApplication] keyWindow];
101+
102+
if (navController.isViewLoaded && navController.view.window) {
103+
// navController is visible only refresh webview
104+
if(_url)
105+
[_webView loadRequest:[NSURLRequest requestWithURL:_url]];
106+
return;
107+
}
108+
101109
if(!viewControllerForPresentation.view.superview)
102110
[mainWindow addSubview:[viewControllerForPresentation view]];
103111

104-
@try {
105-
[viewControllerForPresentation presentViewController:navController animated:YES completion:NULL];
106-
}
107-
@catch(NSException* exception) {
108-
NSLog(@"%@", exception);
109-
}
112+
@try { [viewControllerForPresentation presentViewController:navController animated:YES completion:NULL]; }
113+
@catch(NSException* exception) { }
110114
}
111115

112116

0 commit comments

Comments
 (0)