Skip to content

Commit ddace46

Browse files
committed
Added pushTestMode property and discarded isTestDevice property
1 parent cf47e64 commit ddace46

File tree

5 files changed

+30
-20
lines changed

5 files changed

+30
-20
lines changed

Countly.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ - (void)startWithConfig:(CountlyConfig *)config
121121
if ([config.features containsObject:CLYPushNotifications])
122122
{
123123
CountlyPushNotifications.sharedInstance.isEnabledOnInitialConfig = YES;
124-
CountlyPushNotifications.sharedInstance.isTestDevice = config.isTestDevice;
124+
CountlyPushNotifications.sharedInstance.pushTestMode = config.pushTestMode;
125125
CountlyPushNotifications.sharedInstance.sendPushTokenAlways = config.sendPushTokenAlways;
126126
CountlyPushNotifications.sharedInstance.doNotShowAlertForNotifications = config.doNotShowAlertForNotifications;
127127
CountlyPushNotifications.sharedInstance.launchNotification = config.launchNotification;

CountlyConfig.h

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ extern NSString* const CLYConsentAttribution;
5555
extern NSString* const CLYConsentStarRating;
5656
extern NSString* const CLYConsentAppleWatch;
5757

58+
//NOTE: Push Notification Test Modes
59+
extern NSString* const CLYPushTestModeDevelopment;
60+
extern NSString* const CLYPushTestModeTestFlightOrAdHoc;
5861

5962
@interface CountlyConfig : NSObject
6063

@@ -102,10 +105,20 @@ extern NSString* const CLYConsentAppleWatch;
102105
#pragma mark -
103106

104107
/**
105-
* For manually marking a device as test device for @c CLYPushNotifications feature.
106-
* @discussion Test push notifications can be sent to test devices by selecting "Development & test users only" on "Create Push Notification" section on Countly Server.
108+
* @c isTestDevice property is deprecated. Please use @c pushTestMode property instead.
109+
* @discussion Using this property will have no effect.
110+
*/
111+
@property (nonatomic) BOOL isTestDevice DEPRECATED_MSG_ATTRIBUTE("Use 'pushTestMode' property instead!");;
112+
113+
/**
114+
* For specifying which test mode Countly Server should use for sending push notifications.
115+
* @discussion There are 2 test modes:
116+
* @discussion - @c CLYPushTestModeDevelopment: For development/debug builds signed with a development provisioning profile. Countly Server will send push notifications to Sandbox APNs.
117+
* @discussion - @c CLYPushTestModeTestFlightOrAdHoc: For TestFlight or AdHoc builds signed with a distribution provisioning profile. Countly Server will send push notifications to Production APNs.
118+
* @discussion If set, Test Users mark should be selected on Create Push Notification screen of Countly Server to send push notifications.
119+
* @discussion If not set, Countly Server will use Production APNs by default.
107120
*/
108-
@property (nonatomic) BOOL isTestDevice;
121+
@property (nonatomic) NSString* pushTestMode;
109122

110123
/**
111124
* For sending push tokens to Countly Server even for users who have not granted permission to display notifications.

CountlyConnectionManager.m

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -247,24 +247,17 @@ - (void)sendEvents
247247

248248
- (void)sendPushToken:(NSString *)token
249249
{
250-
typedef enum : NSInteger
251-
{
252-
CLYPushTokenModeProduction,
253-
CLYPushTokenModeDevelopment,
254-
CLYPushTokenModeAdHoc,
255-
} CLYPushTokenMode;
256-
257-
int testMode;
258-
#ifdef DEBUG
259-
testMode = CLYPushTokenModeDevelopment;
260-
#else
261-
testMode = CountlyPushNotifications.sharedInstance.isTestDevice ? CLYPushTokenModeAdHoc : CLYPushTokenModeProduction;
262-
#endif
250+
NSInteger testMode = 0; //NOTE: default is 0: Production - not test mode
251+
252+
if ([CountlyPushNotifications.sharedInstance.pushTestMode isEqualToString:CLYPushTestModeDevelopment])
253+
testMode = 1; //NOTE: 1: Developement/Debug builds - standard test mode using Sandbox APNs
254+
else if ([CountlyPushNotifications.sharedInstance.pushTestMode isEqualToString:CLYPushTestModeTestFlightOrAdHoc])
255+
testMode = 2; //NOTE: 2: TestFlight/AdHoc builds - special test mode using Production APNs
263256

264-
NSString* queryString = [[self queryEssentials] stringByAppendingFormat:@"&%@=%@&%@=%@&%@=%d",
257+
NSString* queryString = [[self queryEssentials] stringByAppendingFormat:@"&%@=%@&%@=%@&%@=%ld",
265258
kCountlyQSKeyPushTokenSession, @"1",
266259
kCountlyQSKeyPushTokeniOS, token,
267-
kCountlyQSKeyPushTestMode, testMode];
260+
kCountlyQSKeyPushTestMode, (long)testMode];
268261

269262
[CountlyPersistency.sharedInstance addToQueue:queryString];
270263

CountlyPushNotifications.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@interface CountlyPushNotifications : NSObject
1010

1111
@property (nonatomic) BOOL isEnabledOnInitialConfig;
12-
@property (nonatomic) BOOL isTestDevice;
12+
@property (nonatomic) NSString* pushTestMode;
1313
@property (nonatomic) BOOL sendPushTokenAlways;
1414
@property (nonatomic) BOOL doNotShowAlertForNotifications;
1515
@property (nonatomic) NSNotification* launchNotification;

CountlyPushNotifications.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
NSString* const kCountlyReservedEventPushAction = @"[CLY]_push_action";
1010
NSString* const kCountlyTokenError = @"kCountlyTokenError";
1111

12+
//NOTE: Push Notification Test Modes
13+
NSString* const CLYPushTestModeDevelopment = @"CLYPushTestModeDevelopment";
14+
NSString* const CLYPushTestModeTestFlightOrAdHoc = @"CLYPushTestModeTestFlightOrAdHoc";
15+
1216
#if (TARGET_OS_IOS || TARGET_OS_OSX)
1317
@interface CountlyPushNotifications () <UNUserNotificationCenterDelegate>
1418
@property (nonatomic) NSString* token;

0 commit comments

Comments
 (0)