Skip to content

Commit d0701fb

Browse files
committed
Misc bug fixes
iOS * Fixed bug where the notificationOpenedCallback would fire again if a page was reloaded/navigated to with OneSignal.init on it. * Launch url now opens Safari much quicker. Android * Fixed bug with getIds where it could fire without a userId set and only a pushToken set on a device with intermittent connection issues.
1 parent d15d805 commit d0701fb

File tree

6 files changed

+20
-7
lines changed

6 files changed

+20
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.9.0",
2+
"version": "1.9.1",
33
"name": "onesignal-cordova-plugin",
44
"cordova_name": "OneSignal Push Notifications",
55
"description": "OneSignal is a high volume Push Notification service for mobile apps. In addition to basic notification delivery, OneSignal also provides tools to localize, target, schedule, and automate notifications that you send.",

plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
33
xmlns:android="http://schemas.android.com/apk/res/android"
44
id="onesignal-cordova-plugin"
5-
version="1.9.0">
5+
version="1.9.1">
66

77
<name>OneSignal Push Notifications</name>
88
<author>Josh Kasten</author>

src/android/libs/OneSignalSDK.jar

29 Bytes
Binary file not shown.

src/ios/OneSignal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ typedef void (^OneSignalHandleNotificationBlock)(NSString* message, NSDictionary
4242

4343
@property(nonatomic, readonly, copy) NSString* app_id;
4444

45-
extern NSString* const VERSION;
45+
extern NSString* const ONESIGNAL_VERSION;
4646

4747
typedef NS_ENUM(NSUInteger, ONE_S_LOG_LEVEL) {
4848
ONE_S_LL_NONE, ONE_S_LL_FATAL, ONE_S_LL_ERROR, ONE_S_LL_WARN, ONE_S_LL_INFO, ONE_S_LL_DEBUG, ONE_S_LL_VERBOSE

src/ios/OneSignal.m

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535

3636
#define DEFAULT_PUSH_HOST @"https://onesignal.com/api/v1/"
3737

38-
NSString* const VERSION = @"011000";
39-
4038
#define NOTIFICATION_TYPE_BADGE 1
4139
#define NOTIFICATION_TYPE_SOUND 2
4240
#define NOTIFICATION_TYPE_ALERT 4
@@ -62,6 +60,8 @@ @interface OneSignal ()
6260

6361
@implementation OneSignal
6462

63+
NSString* const ONESIGNAL_VERSION = @"011001";
64+
6565
@synthesize app_id = _GT_publicKey;
6666
@synthesize httpClient = _GT_httpRequest;
6767
@synthesize lastMessageReceived;
@@ -174,6 +174,7 @@ - (id)initWithLaunchOptions:(NSDictionary*)launchOptions appId:(NSString*)appId
174174
else if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerForRemoteNotifications)])
175175
[[UIApplication sharedApplication] registerForRemoteNotifications];
176176

177+
177178
if (mUserId != nil)
178179
[self registerUser];
179180
else // Fall back incase Apple does not responsed in time.
@@ -371,7 +372,7 @@ - (void)registerUser {
371372
[NSNumber numberWithInt:0], @"device_type",
372373
[[[UIDevice currentDevice] identifierForVendor] UUIDString], @"ad_id",
373374
[self getSoundFiles], @"sounds",
374-
VERSION, @"sdk",
375+
ONESIGNAL_VERSION, @"sdk",
375376
mDeviceToken, @"identifier", // identifier MUST be at the end as it could be nil.
376377
nil];
377378

@@ -396,6 +397,8 @@ - (void)registerUser {
396397
id asIdManager = [ASIdentifierManagerClass valueForKey:@"sharedManager"];
397398
if ([[asIdManager valueForKey:@"advertisingTrackingEnabled"] isEqual:[NSNumber numberWithInt:1]])
398399
dataDic[@"as_id"] = [[asIdManager valueForKey:@"advertisingIdentifier"] UUIDString];
400+
else
401+
dataDic[@"as_id"] = @"OptedOut";
399402
}
400403

401404
UIApplicationReleaseMode releaseMode = [OneSignalMobileProvision releaseMode];
@@ -770,7 +773,9 @@ - (void) handleNotificationOpened:(NSDictionary*)messageDict isActive:(BOOL)isAc
770773

771774
if ([[UIApplication sharedApplication] applicationState] != UIApplicationStateActive && [customDict objectForKey:@"u"] != nil) {
772775
NSURL *url = [NSURL URLWithString:[customDict objectForKey:@"u"]];
773-
[[UIApplication sharedApplication] openURL:url];
776+
dispatch_async(dispatch_get_main_queue(), ^{
777+
[[UIApplication sharedApplication] openURL:url];
778+
});
774779
}
775780

776781
self.lastMessageReceived = messageDict;
@@ -1144,12 +1149,18 @@ static Class getClassWithProtocolInHierarchy(Class searchClass, Protocol* protoc
11441149
return searchClass;
11451150
}
11461151

1152+
1153+
1154+
1155+
1156+
11471157
static void injectSelector(Class newClass, SEL newSel, Class addToClass, SEL makeLikeSel) {
11481158
Method newMeth = class_getInstanceMethod(newClass, newSel);
11491159
IMP imp = method_getImplementation(newMeth);
11501160
const char* methodTypeEncoding = method_getTypeEncoding(newMeth);
11511161

11521162
BOOL successful = class_addMethod(addToClass, makeLikeSel, imp, methodTypeEncoding);
1163+
11531164
if (!successful) {
11541165
class_addMethod(addToClass, newSel, imp, methodTypeEncoding);
11551166
newMeth = class_getInstanceMethod(addToClass, newSel);
@@ -1252,6 +1263,7 @@ + (void)load {
12521263
static Class delegateClass = nil;
12531264

12541265
- (void) setOneSignalDelegate:(id<UIApplicationDelegate>)delegate {
1266+
12551267
if (delegateClass != nil) {
12561268
[self setOneSignalDelegate:delegate];
12571269
return;

src/ios/OneSignalPush.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ void failureCallback(NSString* callbackId, NSDictionary* data) {
5656

5757
void processNotificationOpened(NSDictionary* launchOptions) {
5858
successCallback(notficationOpenedCallbackId, launchOptions);
59+
launchDict = nil;
5960
}
6061

6162
void initOneSignalObject(NSDictionary* launchOptions, const char* appId, BOOL autoRegister) {

0 commit comments

Comments
 (0)