Skip to content

Commit

Permalink
5.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
unity-thull committed Apr 29, 2021
1 parent d60c42e commit 64c577e
Show file tree
Hide file tree
Showing 29 changed files with 175 additions and 48 deletions.
2 changes: 1 addition & 1 deletion Assets/DeltaDNA/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/DeltaDNA/Editor/Android.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions Assets/DeltaDNA/Editor/Android/Dependencies.xml

This file was deleted.

8 changes: 0 additions & 8 deletions Assets/DeltaDNA/Editor/Android/Dependencies.xml.meta

This file was deleted.

25 changes: 25 additions & 0 deletions Assets/DeltaDNA/Editor/ConfigurationWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ private void ApplyAndroidNotificationSettings()
try
{
CopyAndroidNotificationFolder();
CopyAndroidNotificationGradleFiles();
// Inform the user that the plugin has been correctly configured in their assets folder
Debug.Log(
"deltaDNA Android notification setup complete. The configured plugin has been updated in your Assets/Plugins/Android folder"
Expand Down Expand Up @@ -348,6 +349,30 @@ private void CopyAndroidNotificationFolder()
AssetDatabase.ImportAsset(assetPath);
}

private void CopyAndroidNotificationGradleFiles()
{
string[] fileNames = {"baseProjectTemplate.gradle", "gradleTemplate.properties", "mainTemplate.gradle"};
foreach (var fileName in fileNames)
{
string sourceFolder = Path.GetFullPath(WindowHelper.FindDir("Runtime/Plugins/Android"));
string sourceFile = $"{sourceFolder}/{fileName}";
string targetPath = $"Plugins/Android/{fileName}";
string targetFile = $"{Application.dataPath}/{targetPath}";
string assetTargetPath = $"Assets/{targetPath}";

if (File.Exists(targetFile))
{
Debug.Log(
"An existing gradle template file was found when copying DeltaDNA notification files. " +
"The template was not copied, but can be accessed and manually added from DeltaDNA/Runtime/Plugins/Android if required");
continue;
}
AssetDatabase.DeleteAsset(assetTargetPath);
File.Copy(sourceFile, targetFile);
AssetDatabase.ImportAsset(assetTargetPath);
}
}

// Adapted from https://docs.microsoft.com/en-us/dotnet/standard/io/how-to-copy-directories
// as there was no inbuilt method to copy a directory recursively.
private static void DirectoryCopy(string sourceDirName, string destDirName)
Expand Down
2 changes: 1 addition & 1 deletion Assets/DeltaDNA/Editor/ConfigurationWindow.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/DeltaDNA/Editor/DefineSymbolsHelper.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/DeltaDNA/Editor/DeltaDNASdkChecker.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/DeltaDNA/Editor/InitialisationHelper.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/DeltaDNA/Editor/MenuItems.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/DeltaDNA/Editor/Resources.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/DeltaDNA/Editor/SdkChecker.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/DeltaDNA/Editor/WindowHelper.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/DeltaDNA/Editor/iOS.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Assets/DeltaDNA/Runtime/AudiencePinpointer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public static class AudiencePinpointer
#if UNITY_IOS
[DllImport("__Internal")]
private static extern int ddna_get_tracking_status();

[DllImport("__Internal")]
private static extern bool ddna_is_tracking_authorized();
#endif
/// <summary>
/// Record this event when a new gameplay session is started.
Expand Down Expand Up @@ -104,7 +107,7 @@ internal PinpointerEvent(string name) : base(name)

AddParam("attTrackingStatus", ddna_get_tracking_status());

bool idfaPresent = UnityEngine.iOS.Device.advertisingTrackingEnabled;
bool idfaPresent = ddna_is_tracking_authorized();

AddParam("idfv", UnityEngine.iOS.Device.vendorIdentifier);
if (idfaPresent)
Expand Down
2 changes: 1 addition & 1 deletion Assets/DeltaDNA/Runtime/Helpers/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace DeltaDNA
{
public class Settings
{
public static readonly string SDK_VERSION = "Unity SDK v5.0.6";
public static readonly string SDK_VERSION = "Unity SDK v5.0.7";

internal static readonly string ENGAGE_API_VERSION = "4";

Expand Down
36 changes: 36 additions & 0 deletions Assets/DeltaDNA/Runtime/Plugins/Android/baseProjectTemplate.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
allprojects {
buildscript {
repositories {**ARTIFACTORYREPOSITORY**
google()
jcenter()
}

dependencies {
// If you are changing the Android Gradle Plugin version, make sure it is compatible with the Gradle version preinstalled with Unity
// See which Gradle version is preinstalled with Unity here https://docs.unity3d.com/Manual/android-gradle-overview.html
// See official Gradle and Android Gradle Plugin compatibility table here https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
// To specify a custom Gradle version in Unity, go do "Preferences > External Tools", uncheck "Gradle Installed with Unity (recommended)" and specify a path to a custom Gradle version
classpath 'com.android.tools.build:gradle:3.4.0'
**BUILD_SCRIPT_DEPS**
}
}

repositories {**ARTIFACTORYREPOSITORY**
google()
jcenter()
maven {
url 'https://maven.pkg.github.com/deltaDNA/android-sdk'
credentials {
username = "omur-deltadna"
password = "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"
}
}
flatDir {
dirs "${project(':unityLibrary').projectDir}/libs"
}
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.deltadna.android.sdk.notifications.unity">
<application>
<service android:name="com.deltadna.android.sdk.notifications.NotificationListenerService" android:enabled="false">
<service android:name="com.deltadna.android.sdk.notifications.NotificationListenerService" android:enabled="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<meta-data android:name="ddna_sender_id" android:resource="@string/ddna_sender_id" />
<meta-data android:name="ddna_fcm_api_key" android:resource="@string/ddna_fcm_api_key" />
<meta-data android:name="ddna_application_id" android:resource="@string/ddna_application_id" />
<meta-data android:name="ddna_fcm_project_id" android:resource="@string/ddna_fcm_project_id" />
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<resources />
<resources>
<string name="ddna_application_id">1:3185998592:android:f8cfe35d6825f6f8af51e5</string>
<string name="ddna_sender_id">3185998592</string>
<string name="ddna_fcm_project_id">deltadna-dev</string>
<string name="ddna_fcm_api_key">AIzaSyCzjaIBsecb09zp_Y7Njac9bnLzirQWMbM</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
org.gradle.parallel=true
**ADDITIONAL_PROPERTIES**

android.useAndroidX = true
39 changes: 39 additions & 0 deletions Assets/DeltaDNA/Runtime/Plugins/Android/mainTemplate.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apply plugin: 'com.android.library'
**APPLY_PLUGINS**

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.deltadna.android:deltadna-sdk-notifications:4.13.4'
**DEPS**}

android {
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
minSdkVersion **MINSDKVERSION**
targetSdkVersion **TARGETSDKVERSION**
ndk {
abiFilters **ABIFILTERS**
}
versionCode **VERSIONCODE**
versionName '**VERSIONNAME**'
consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
}

lintOptions {
abortOnError false
}

aaptOptions {
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}**PACKAGING_OPTIONS**
}**REPOSITORIES**
**IL_CPP_BUILD_SETUP**
**SOURCE_BUILD_SETUP**
**EXTERNAL_SOURCES**
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <AppTrackingTransparency/ATTrackingManager.h>
#include <Foundation/Foundation.h>
#include <AdSupport/ASIdentifierManager.h>

int ddna_get_tracking_status() {
if (@available(iOS 14, *)) {
Expand All @@ -9,3 +10,11 @@ int ddna_get_tracking_status() {
return -1;
}
}

bool ddna_is_tracking_authorized() {
if (@available(iOS 14, *)) {
return [ATTrackingManager trackingAuthorizationStatus] == 3;
} else {
return [[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled];
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## [5.0.7-preview] - 2021-04-29

### Changed
- Use Unity's in-built gradle instead of Unity Jar Resolver for resolving android dependencies (due to bintray deprecation, reconfiguring android notifications required)

### Fixed
- Correctly report IDFA in signal events on iOS 14.5+

## [5.0.6-preview] - 2021-04-27

### Fixed
Expand Down
33 changes: 26 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

## deltaDNA Unity SDK

The latest version of the analytics SDK is supported in Unity 2018.4 and newer.

The SDK is distributed as a unitypackage file which can be downloaded from GitHub [releases](https://github.com/deltaDNA/unity-sdk/releases). Import into Unity with Assets->Import Package->Custom Package. If you are updating the SDK it is recommended to remove the *Assets/DeltaDNA* and *Assets/DeltaDNAAds* folders before importing the new package.
The repository contains sources for the deltaDNA Unity SDK. The SDK is distributed as a unitypackage file which can be downloaded from GitHub [releases](https://github.com/deltaDNA/unity-sdk/releases). Import into Unity with Assets->Import Package->Custom Package. If you are updating the SDK it is recommended to remove the *Assets/DeltaDNA* and *Assets/DeltaDNAAds* folders before importing the new package.

deltaDNA SDK [Download](https://github.com/deltaDNA/unity-sdk/releases)

The analytics SDK is supported in both Unity 4, Unity 5, 201x and 2020.

## Contents

Expand Down Expand Up @@ -225,7 +224,7 @@ The DeltaDNA service allows you to send notifications with additional content su
![DeltaDNA Unity Editor configuration](images/ios_delta_dna_configuration.png)

3. Build the iOS project.
4. If you are using Unity editor 2018.4 - 2019.2, you will also need to change the Xcode build system within Xcode (File -> Project Settings -> Build System) to be the legacy build system. This is done automatically for Unity editor versions 2019.3 or higher.
4. Change the Xcode build system within Xcode (File -> Project Settings -> Build System) to be the legacy build system.

![Xcode Build System Change](images/ios_build_system_change.png)

Expand All @@ -245,10 +244,25 @@ DDNA.Instance.Platform = DeltaDNA.Platform.AMAZON;
DDNA.Instance.StartSDK();
```

### Android Dependencies Google Firebase/Play Services Libraries
### Android Dependencies

#### v5.0.7 onwards

The android dependencies for this SDK are fetched using Unity's gradle build. This is achieved through a custom gradle template file - this will be copied into your assets folder when you apply the Android notification settings.

If the SDK detects you already have a gradle template file, it will not copy the file to avoid overwriting your existing code. In order to use notifications with the deltaDNA SDK you will need to add our notifications plugin manually to this template, using the provided templates for reference (these are found in `DeltaDNA/Runtime/Plugins/Android`).

If you are upgrading from a version previous to 5.0.7, you may need to remove the assets copied by previous versions of the SDK, and remove the resolver mentioned below. If you then apply the notification settings,
the new structure will be copied to your assets folder as above.

As of 5.0.7 we no longer use the Unity Jar Resolver.

#### < v5.0.6

Any library dependencies such as Google's Firebase (Google Play Services) are handled by Google's [Unity Jar Resolver](https://github.com/googlesamples/unity-jar-resolver) plugin. The libraries will be automatically downloaded into the *Assets/Plugins/Android* folder. If you have other Unity plugins in your application which don't use the Resolver for downloading dependencies you may want to consider using the Resolver to manage their dependencies as well, otherwise you may have to manually resolve any conflicts.

> Note that occassionaly there can be conflicts between different versions of the resolver, if other plugins are included that also use it. If such conflicts occur, you can safely remove the bundled version of the resolver from the deltaDNA plugin and use one from another source, and it should still resolve the DeltaDNA plugin dependencies correctly.
### Push Notifications

Our push notifications use Firebase messaging (this was changed in version 4.3, if you're upgrading see the migration [guide](#version-4.3) below). In order to configure notifications you will need to set the *Application* and *Sender IDs* from the configuration UI, which can be accessed from the Unity Editor menu under *DeltaDNA -> Configure*. The IDs can be found in the Firebase Console for your application ([1](Docs/firebase_console_1.png), [2](Docs/firebase_console_2.png), and [3](Docs/firebase_console_3.png)). Pressing *Apply* will persist the changes to resource files in your project, which should be committed to source control.
Expand All @@ -257,7 +271,10 @@ If your application is setup using the Google Cloud Console you can find instruc

The style of the push notifications can be changed by overriding the behaviour of the library. Instructions on how to do this can be found [here](https://github.com/deltaDNA/android-sdk/tree/master/library-notifications#unity). Once you have added either the modified library or added the new classes as a separate library you will need to change the *Listener Service* field in the configuration to the fully qualified name of your new class.

If you no longer wish to use push notifications on Android then you can remove the *Assets/Plugins/Android/deltadna-sdk-unity-notifications* folder and *Assets/DeltaDNA/Editor/Android/Dependencies.xml* from the project to decrease the number of methods and the APK size of your game.
If you no longer wish to use push notifications on Android then you can remove the *Assets/Plugins/Android/deltadna-sdk-unity-notifications* folder (and *Assets/DeltaDNA/Editor/Android/Dependencies.xml* if you are using a version of the SDK <5.0.7) from the project to decrease the number of methods and the APK size of your game.

#### Existing Firebase Cloud Messaging SDK
If you already use Firebase's Cloud Messaging SDK, you may experience issues receiving notifications using deltaDNA's SDK, as only one receiver can use each Firebase Cloud Messaging configuration in an application at a time. To fix this, you can either remove your existing Firebase Cloud Messaging SDK, or you will need to create a separate project for deltaDNA with a new sender ID in the Firebase Console. If you choose to create a new project, make sure that the configuration for deltaDNA in the Unity Editor is updated to use the new project, and ensure the server API key under the Identities section of the deltaDNA portal is updated to use details from the same project.

### MultiDex; Working Around Android's 65k Method Limit
1. Export your Unity project using the *Gradle* build system. These options can be found in the *Build Settings* dialog.
Expand Down Expand Up @@ -305,7 +322,7 @@ If the game supports changing of users then calling `StartSdk(userID)` with a ne
## Migrations

### Version 4.3
Between version 4.2 and version 4.3 we updated our push notifications to use Firebase (play-services-*-10.2). This requires changing the way push notification integration works. To better manage the Android dependencies we now use Google's [Unity Jar Resolver](https://github.com/googlesamples/unity-jar-resolver). This allows other plugins to also specify dependencies on the Firebase/Play-Services libraries and the Unity Jar Resolver will work out which library to use, hopefully reducing duplicate library errors at build time.
Between version 4.2 and version 4.3 we updated our push notifications to use Firebase (`play-services-*-10.2`). This requires changing the way push notification integration works. To better manage the Android dependencies we now use Google's [Unity Jar Resolver](https://github.com/googlesamples/unity-jar-resolver). This allows other plugins to also specify dependencies on the Firebase/Play-Services libraries and the Unity Jar Resolver will work out which library to use, hopefully reducing duplicate library errors at build time.

### Version 4.7
*IosNetworksLoadHelper.cs* should be deleted from *Assets/DeltaDNA/Ads/Editor/Menus/Networks/* as the file has been replaced by *InitialisationHelper.cs*.
Expand Down Expand Up @@ -346,6 +363,8 @@ The settings for this feature are stored in `ddna_api_configuation.xml` - please

The sources are available under the Apache 2.0 license.

By integrating, accessing, or using the deltaDNA UA SDK, you acknowledge and agree that (1) your access to and use of the deltaDNA UA SDK is governed by Unity’s Monetization Terms of Service, available [here](https://unity3d.com/legal/monetization-services-terms-of-service), and that such service is an Experimental Service (as defined therein); and (2) you will not access or use the deltaDNA UA SDK in connection with any application that is “directed to children” under the age of 13 or would otherwise be subject to the Children’s Online Privacy Protection Act of 1998, or with any application designated as a “Kids” or “Family” application in the Apple App Store or Google Play Store.

## Contact Us

For more information, please visit [deltadna.com](https://deltadna.com/). For questions or assistance, please email us at [support@deltadna.com](mailto:support@deltadna.com).

0 comments on commit 64c577e

Please sign in to comment.