Skip to content

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
Release 4.11.5

See merge request gamesanalytics/ios-sdk-v4!38
  • Loading branch information
Chris Aitken committed Nov 14, 2019
2 parents 71d10d0 + 994a60b commit 0511698
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## [4.11.5](https://github.com/deltaDNA/ios-sdk/releases/tag/4.11.5)
### Fixed
- Add push notification token support for iOS13

## [4.11.4](https://github.com/deltaDNA/ios-sdk/releases/tag/4.11.4)
### Fixed
- Issue with persistence to avoid an edge-case crash
Expand Down
2 changes: 1 addition & 1 deletion DeltaDNA.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'DeltaDNA'
s.version = '4.11.4'
s.version = '4.11.5'
s.license = { :type => 'APACHE', :file => 'LICENSE' }
s.summary = 'A gaming analytics platform.'
s.homepage = 'https://deltadna.com'
Expand Down
6 changes: 6 additions & 0 deletions DeltaDNA/DDNANonTrackingSdk.m
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ - (void)setPushNotificationToken:(NSString *)token
self.sdk.pushNotificationToken = token;
}

- (void)setDeviceToken:(NSData *)token
{
// do nothing
}


- (void)downloadImageAssets
{
// do nothing
Expand Down
17 changes: 13 additions & 4 deletions DeltaDNA/DDNASDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,21 @@
/**
The Apple push notification token. Set this @b before starting
the SDK to enable DeltaDNA to send push notifications to your
game.
@see http://docs.deltadna.com/ios-sdk/#PushNotification for
game.
@see https://docs.deltadna.com/advanced-integration/ios-sdk/#push-notifications for
an example of how to get the token.
*/
@property (nonatomic, copy) NSString *pushNotificationToken;

@property (nonatomic, copy) NSString *pushNotificationToken __attribute__((deprecated("Replaced by setDeviceToken - Please see README for updated usage.")));

/**
The Apple Device Token received from in your AppDelegate
didRegisterForRemoteNotificationsWithDeviceToken.
Set this @b before starting the SDK to enable DeltaDNA
to send push notifications to your game.
*/
@property (nonatomic, copy) NSData *deviceToken;

/// The environment key for this game environment (Dev or Live).
@property (nonatomic, copy, readonly) NSString *environmentKey;
Expand Down
6 changes: 6 additions & 0 deletions DeltaDNA/DDNASDK.m
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ - (void) setPushNotificationToken:(NSString *)pushNotificationToken
[self.impl setPushNotificationToken:pushNotificationToken];
}

-(void) setDeviceToken:(NSData *)deviceToken
{
_deviceToken = deviceToken;
[self.impl setDeviceToken:deviceToken];
}

- (BOOL)hasStarted
{
return [self.impl hasStarted];
Expand Down
2 changes: 1 addition & 1 deletion DeltaDNA/DDNASdkInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@

- (void)setCrossGameUserId:(NSString *)crossGameUserId;
- (void)setPushNotificationToken:(NSString *)pushNotificationToken;

- (void)setDeviceToken:(NSData *)deviceToken;
@end
2 changes: 1 addition & 1 deletion DeltaDNA/DDNASettings.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#import "DDNASettings.h"

NSString *const DDNA_SDK_VERSION = @"iOS SDK v4.11.4";
NSString *const DDNA_SDK_VERSION = @"iOS SDK v4.11.5";
NSString *const DDNA_ENGAGE_API_VERSION = @"4";

NSString *const DDNA_EVENT_STORAGE_PATH = @"{persistent_path}";
Expand Down
24 changes: 19 additions & 5 deletions DeltaDNA/DDNATrackingSdk.m
Original file line number Diff line number Diff line change
Expand Up @@ -406,18 +406,32 @@ - (void) setCrossGameUserId:(NSString *)crossGameUserId
- (void) setPushNotificationToken:(NSString *)pushNotificationToken
{
if (_started) {
NSString *token = [pushNotificationToken stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
token = [token stringByReplacingOccurrencesOfString:@" " withString:@""];
[[self.sdk recordEventWithName:@"notificationServices" eventParams:@{
@"pushNotificationToken": token
}] run] ;
DDNALogDebug(@"DeltaDNA SDK Set PushNotificationToken %@", pushNotificationToken);
} else {
__typeof(self) __weak weakSelf = self;
dispatch_async(_taskQueue, ^{
[weakSelf setPushNotificationToken:pushNotificationToken];
});
}
}
-(void) setDeviceToken:(NSData *)deviceToken{

NSUInteger length = deviceToken.length;
if (length > 0)
{
const unsigned char *buffer = (const unsigned char *) deviceToken.bytes;
NSMutableString *tokenString =[NSMutableString stringWithCapacity:(length*2)];
for(int i=0; i<length ; i++)
{
[tokenString appendFormat:@"%02x",buffer[i]];
}
self.sdk.pushNotificationToken = tokenString;
NSLog(@"DeltaDNA SDK Set PushNotificationToken %@", tokenString);
[[self.sdk recordEventWithName:@"notificationServices" eventParams:@{
@"pushNotificationToken": tokenString
}] run] ;
}
}

- (void)clearPersistentData
{
Expand Down
4 changes: 3 additions & 1 deletion Example/iOS Example/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ - (void)applicationWillTerminate:(UIApplication *)application {

- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
[DDNASDK sharedInstance].pushNotificationToken = [deviceToken description];
// From iOS13 onward, setting the pushNotificationToken from the description property no longer works
// Please update your app to set the deviceToken instead.
[[DDNASDK sharedInstance] setDeviceToken: deviceToken];
}

- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
Expand Down
2 changes: 1 addition & 1 deletion README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ target 'MyApp' do
# 如果你使用Swift或者想要使用动态框架,请取消此行注释
use_frameworks!

pod 'DeltaDNA', '~> 4.11.4'
pod 'DeltaDNA', '~> 4.11.5'

target 'MyAppTests' do
inherit! :search_paths
Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ target 'MyApp' do
# Uncomment this line if you're using Swift or would like to use dynamic frameworks
use_frameworks!

pod 'DeltaDNA', '~> 4.11.4'
pod 'DeltaDNA', '~> 4.11.5'

target 'MyAppTests' do
inherit! :search_paths
Expand Down Expand Up @@ -229,6 +229,18 @@ When a cross promotion campaign with a store action has been acted on by the use

In order to help with GDPR compliance, calling `forgetMe` on the sdk sends an event to the platform indicating the user wishes their previously collected data to be deleted. Once called the sdk will no longer record events and Engage requests will return empty responses. No additional calls are required on the sdk since it will appear to work correctly from the caller's point of view. The sdk can be reset by either calling `clearPersistantData` or starting with a new user id.


### Push Notifications
In order to enable receive notifications you will need to send the deviceToken received in the didRegisterForRemoteNotificationsWithDeviceToken method in your AppDelegate.m to deltaDNA
```objective-c
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
// From iOS13 onward, setting the pushNotificationToken from the description property no longer works
// Please update your app to set the deviceToken instead.
[DDNASDK sharedInstance].deviceToken = deviceToken;
}
```

### Further Integration

Refer to our [documentation](http://docs.deltadna.com/advanced-integration/ios-sdk/) site for more details on how to use the SDK.
Expand Down

0 comments on commit 0511698

Please sign in to comment.