Skip to content

Commit

Permalink
6.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
unity-thull committed May 30, 2022
1 parent 8c6e7a8 commit 0b0754e
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static void CreateRichPushNotificationTarget(BuildTarget buildTarget, str

string guidOfInitialTarget = GetTargetGuid(project);

string pathToInfoPlist = Path.Combine(buildOutputPath, PATH_TO_INFO_PLIST_INSIDE_TARGET);
string pathToInfoPlist = buildOutputPath + "/" + PATH_TO_INFO_PLIST_INSIDE_TARGET;
PlistDocument mainProjectInfoPlist = new PlistDocument();
mainProjectInfoPlist.ReadFromFile(pathToInfoPlist);
PlistElementArray array = mainProjectInfoPlist.root.CreateArray("UIBackgroundModes");
Expand All @@ -55,29 +55,30 @@ public static void CreateRichPushNotificationTarget(BuildTarget buildTarget, str
int indexOfLastIdentifierSection = bundleIdentifierForNotificationService.LastIndexOf('.') + 1;
string displayName = bundleIdentifierForNotificationService.Substring(indexOfLastIdentifierSection);

string pathToNotificationServiceImplementation = Path.Combine(buildOutputPath, displayName);
string pathToNotificationServiceImplementation = buildOutputPath + "/" + displayName;

if (!Directory.Exists(pathToNotificationServiceImplementation))
{
Directory.CreateDirectory(pathToNotificationServiceImplementation);
}

PlistDocument notificationServicePlist = new PlistDocument();
string plistTemplatePath = Path.Combine(GetPathToSourceDirectory(), "Info.plist");
string plistTemplatePath = GetPathToSourceDirectory() + "/" + "Info.plist";
notificationServicePlist.ReadFromFile(plistTemplatePath);
notificationServicePlist.root.SetString("CFBundleDisplayName", displayName);
notificationServicePlist.root.SetString("CFBundleIdentifier", bundleIdentifierForNotificationService);
notificationServicePlist.root.SetString("CFBundleShortVersionString", PlayerSettings.bundleVersion);
notificationServicePlist.root.SetString("CFBundleVersion", PlayerSettings.iOS.buildNumber);

string pathToNotificationServicePlist = Path.Combine(pathToNotificationServiceImplementation, PATH_TO_INFO_PLIST_INSIDE_TARGET);
string pathToNotificationServicePlist = pathToNotificationServiceImplementation + "/" + PATH_TO_INFO_PLIST_INSIDE_TARGET;
notificationServicePlist.WriteToFile(pathToNotificationServicePlist);

string guidOfExtension = PBXProjectExtensions.AddAppExtension(
project, guidOfInitialTarget,
project,
guidOfInitialTarget,
displayName,
bundleIdentifierForNotificationService,
pathToNotificationServicePlist
displayName + "/" + PATH_TO_INFO_PLIST_INSIDE_TARGET
);
string buildPhaseId = project.AddSourcesBuildPhase(guidOfExtension);

Expand All @@ -99,7 +100,6 @@ public static void CreateRichPushNotificationTarget(BuildTarget buildTarget, str
);
AddFileToProject(
project,
pathToNotificationServicePlist,
"Info.plist",
displayName,
guidOfExtension,
Expand Down Expand Up @@ -150,26 +150,26 @@ private static void AddSourceFileToProject(
string pathToImplementation
)
{
string sourceFilepath = Path.Combine(GetPathToSourceDirectory(), filename);
string destinationFilepath = Path.Combine(pathToImplementation, filename);
string sourceFilepath = GetPathToSourceDirectory() + "/" + filename;
string destinationFilepath = pathToImplementation + "/" + filename;
if (File.Exists(destinationFilepath))
{
File.Delete(destinationFilepath);
}
File.Copy(sourceFilepath, destinationFilepath);
string fileGUID = AddFileToProject(project, destinationFilepath, filename, extensionDisplayName, extensionGuid, buildPhase);
string fileGUID = AddFileToProject(project, filename, extensionDisplayName, extensionGuid, buildPhase);
project.AddFileToBuildSection(extensionGuid, buildPhase, fileGUID);
}

private static string GetPathToSourceDirectory()
{
return Path.Combine("Assets", "DeltaDNA", "Editor", "iOS", "NotificationService");
return string.Join("/", "Assets", "DeltaDNA", "Editor", "iOS", "NotificationService");
}

private static string AddFileToProject(PBXProject project, string filepath, string filename, string extensionDisplayName, string extensionGuid, string buildPhase)
private static string AddFileToProject(PBXProject project, string filename, string extensionDisplayName, string extensionGuid, string buildPhase)
{
string xcodePath = extensionDisplayName + "/" + filename;
return project.AddFile(filepath, xcodePath);
return project.AddFile(xcodePath, xcodePath);
}
}
#endif
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 v6.0.2";
public static readonly string SDK_VERSION = "Unity SDK v6.0.3";

internal static readonly string ENGAGE_API_VERSION = "4";

Expand Down
17 changes: 15 additions & 2 deletions Assets/DeltaDNA/Runtime/Helpers/SimpleDataStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public abstract class SimpleDataStore<K, V>{

private static object LOCK = new object();

private readonly string location = Application.temporaryCachePath + "/deltadna/";
private readonly string location;
private readonly string storename;

private Dictionary<K, V> data;
Expand All @@ -20,13 +20,16 @@ internal SimpleDataStore(string directory, string storename, char paramSeparator

directory = !directory.EndsWith("/") ? directory + "/" : directory;

this.location = Application.temporaryCachePath + "/deltadna/" + directory;
this.location = Application.persistentDataPath + "/deltadna/" + directory;

this.paramSeparator = paramSeparator;
this.storename = storename;

lock (LOCK) {
CreateDirectory();

MigrateFromOldCacheFile(directory);

if (File.Exists(location + storename)) {
data = File
.ReadAllLines(location + storename)
Expand Down Expand Up @@ -92,6 +95,16 @@ protected char getKeyValueSeparator(){
return this.paramSeparator;
}

private void MigrateFromOldCacheFile(string directory)
{
string oldPath = Application.temporaryCachePath + "/deltadna/" + directory + storename;
string newPath = location + storename;

if (File.Exists(oldPath) && !File.Exists(newPath))
{
File.Move(oldPath, newPath);
}
}
}

}
Expand Down
33 changes: 25 additions & 8 deletions Assets/DeltaDNA/Runtime/Messaging/ImageMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,10 @@ public bool IsReady(){

public void Show(){
if (IsReady()){
try{
if (spriteMap.Texture == null){
try
{
if (spriteMap.Texture == null)
{
/*
* This is a workaround for when we're showing for an
* event trigger, as the instance didn't go through the
Expand All @@ -239,15 +241,17 @@ public void Show(){
messageCanvas.sortingOrder = 32767;
gameObject.AddComponent<GraphicRaycaster>();

if (this.configuration.ContainsKey("shim")){
if (this.configuration.ContainsKey("shim"))
{
ShimLayer shimLayer = gameObject.AddComponent<ShimLayer>();
shimLayer.Build(ddna, gameObject, this, this.configuration["shim"] as JSONObject, this.depth);
}

JSONObject layout = configuration["layout"] as JSONObject;
object orientation;
if (!layout.TryGetValue("landscape", out orientation) &&
!layout.TryGetValue("portrait", out orientation)){
!layout.TryGetValue("portrait", out orientation))
{
throw new KeyNotFoundException("Layout missing orientation key.");
}

Expand All @@ -261,11 +265,15 @@ public void Show(){

showing = true;
}
catch (KeyNotFoundException exception){
catch (KeyNotFoundException exception)
{
Logger.LogWarning("Failed to show image message, invalid format: " + exception.Message);
HideImageMessageObject();
}
catch (Exception exception){
catch (Exception exception)
{
Logger.LogWarning("Failed to show image message: " + exception.Message);
HideImageMessageObject();
}
}
}
Expand All @@ -276,9 +284,18 @@ public bool IsShowing(){

public void Close(){
if (showing){
UnityEngine.Object.Destroy(gameObject);
showing = false;
HideImageMessageObject();
}
}

private void HideImageMessageObject()
{
if (gameObject != null)
{
Object.Destroy(gameObject);
}

showing = false;
}

public JSONObject Parameters{ get; private set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'com.android.library'

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

android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'com.android.library'

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

android {
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [6.0.3]

### Fixed
- Event trigger counts will now be correctly persisted across sessions
- iOS Rich Push Notifications will build correctly when project is moved between different systems between Unity and Xcode builds

## [6.0.2]

### Fixed
Expand Down

0 comments on commit 0b0754e

Please sign in to comment.