Skip to content

Commit ea1cdab

Browse files
committed
Replaced MobileProvision header + added the usableDeviceToken method
1 parent f3b49e3 commit ea1cdab

File tree

5 files changed

+27
-61
lines changed

5 files changed

+27
-61
lines changed
15.6 KB
Binary file not shown.
-328 KB
Binary file not shown.

iOS_SDK/OneSignal/OneSignal.m

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,9 @@ + (void)registerForPushNotifications {
292292
+ (void)IdsAvailable:(OSIdsAvailableBlock)idsAvailableBlock {
293293

294294
if (mUserId)
295-
idsAvailableBlock(mUserId, mDeviceToken);
295+
idsAvailableBlock(mUserId, [self getUsableDeviceToken]);
296296

297-
if (!mUserId || !mDeviceToken)
297+
if (!mUserId || ![self getUsableDeviceToken])
298298
idsAvailableBlockWhenReady = idsAvailableBlock;
299299
}
300300

@@ -540,8 +540,8 @@ + (void)updateDeviceToken:(NSString*)deviceToken onSuccess:(OSResultSuccessBlock
540540

541541
if (idsAvailableBlockWhenReady) {
542542
mNotificationTypes = [self getNotificationTypes];
543-
if (mDeviceToken) {
544-
idsAvailableBlockWhenReady(mUserId, mDeviceToken);
543+
if ([self getUsableDeviceToken]) {
544+
idsAvailableBlockWhenReady(mUserId, [self getUsableDeviceToken]);
545545
idsAvailableBlockWhenReady = nil;
546546
}
547547
}
@@ -683,7 +683,7 @@ + (void)registerUser {
683683
}
684684

685685
if (idsAvailableBlockWhenReady) {
686-
idsAvailableBlockWhenReady(mUserId, mDeviceToken);
686+
idsAvailableBlockWhenReady(mUserId, [self getUsableDeviceToken]);
687687
if (mDeviceToken)
688688
idsAvailableBlockWhenReady = nil;
689689
}
@@ -697,6 +697,10 @@ + (void)registerUser {
697697
}];
698698
}
699699

700+
+(NSString*) getUsableDeviceToken {
701+
return (mNotificationTypes > 0) ? mDeviceToken : NULL;
702+
}
703+
700704
//Updates the server with the new user's notification Types
701705
+ (void) sendNotificationTypesUpdate:(BOOL)isNewType {
702706

@@ -715,8 +719,8 @@ + (void) sendNotificationTypesUpdate:(BOOL)isNewType {
715719

716720
[OneSignalHelper enqueueRequest:request onSuccess:nil onFailure:nil];
717721

718-
if (mDeviceToken && idsAvailableBlockWhenReady) {
719-
idsAvailableBlockWhenReady(mUserId, mDeviceToken);
722+
if ([self getUsableDeviceToken] && idsAvailableBlockWhenReady) {
723+
idsAvailableBlockWhenReady(mUserId, [self getUsableDeviceToken]);
720724
idsAvailableBlockWhenReady = nil;
721725
}
722726
}
@@ -926,8 +930,8 @@ + (void) updateNotificationTypes:(int)notificationTypes {
926930
else if (mDeviceToken)
927931
[self sendNotificationTypesUpdate:changed];
928932

929-
if (idsAvailableBlockWhenReady && mUserId && mDeviceToken)
930-
idsAvailableBlockWhenReady(mUserId, mDeviceToken);
933+
if (idsAvailableBlockWhenReady && mUserId && [self getUsableDeviceToken])
934+
idsAvailableBlockWhenReady(mUserId, [self getUsableDeviceToken]);
931935
}
932936

933937
+ (void)didRegisterForRemoteNotifications:(UIApplication*)app deviceToken:(NSData*)inDeviceToken {

iOS_SDK/OneSignalMobileProvision/OneSignalMobileProvision.h

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,10 @@
1-
/**
2-
* Modified MIT License
3-
*
4-
* Copyright 2016 OneSignal
5-
*
6-
* Permission is hereby granted, free of charge, to any person obtaining a copy
7-
* of this software and associated documentation files (the "Software"), to deal
8-
* in the Software without restriction, including without limitation the rights
9-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10-
* copies of the Software, and to permit persons to whom the Software is
11-
* furnished to do so, subject to the following conditions:
12-
*
13-
* 1. The above copyright notice and this permission notice shall be included in
14-
* all copies or substantial portions of the Software.
15-
*
16-
* 2. All copies of substantial portions of the Software may only be used in connection
17-
* with services provided by OneSignal.
18-
*
19-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25-
* THE SOFTWARE.
26-
*/
1+
//
2+
// OneSignalMobileProvision.h
3+
// Renamed from UIApplication+BSMobileProvision.h to prevent conflicts
4+
//
5+
// Created by kaolin fire on 2013-06-24.
6+
// Copyright (c) 2013 The Blindsight Corporation. All rights reserved.
7+
// Released under the BSD 2-Clause License (see LICENSE)
278

289
typedef NS_ENUM(NSInteger, UIApplicationReleaseMode) {
2910
UIApplicationReleaseUnknown,

iOS_SDK/OneSignalMobileProvision/OneSignalMobileProvision.m

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,10 @@
1-
/**
2-
* Modified MIT License
3-
*
4-
* Copyright 2016 OneSignal
5-
*
6-
* Permission is hereby granted, free of charge, to any person obtaining a copy
7-
* of this software and associated documentation files (the "Software"), to deal
8-
* in the Software without restriction, including without limitation the rights
9-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10-
* copies of the Software, and to permit persons to whom the Software is
11-
* furnished to do so, subject to the following conditions:
12-
*
13-
* 1. The above copyright notice and this permission notice shall be included in
14-
* all copies or substantial portions of the Software.
15-
*
16-
* 2. All copies of substantial portions of the Software may only be used in connection
17-
* with services provided by OneSignal.
18-
*
19-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25-
* THE SOFTWARE.
26-
*/
1+
//
2+
// OneSignalMobileProvision.m
3+
// Renamed from UIApplication+BSMobileProvision.m to prevent conflicts
4+
//
5+
// Created by kaolin fire on 2013-06-24.
6+
// Copyright (c) 2013 The Blindsight Corporation. All rights reserved.
7+
// Released under the BSD 2-Clause License (see LICENSE)
278

289
#import "OneSignalMobileProvision.h"
2910
#import "TargetConditionals.h"

0 commit comments

Comments
 (0)