Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [2.0.0-pre.2] - 2022-05-09

### Fixed

* Fixed a documentation bug
* Fixed a compile issue that could occur if custom Editor classes were added to a Unity project
  • Loading branch information
Unity Technologies committed May 9, 2022
1 parent 2273f7f commit 72d9171
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 41 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [2.0.0-pre.2] - 2022-05-09

### Fixed

* Fixed a documentation bug
* Fixed a compile issue that could occur if custom Editor classes were added to a Unity project

## [2.0.0-pre.1] - 2022-05-06

### New Features

Expand Down
4 changes: 2 additions & 2 deletions Documentation~/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ A full code sample is shown below.
await UnityServices.InitializeAsync();
// Note: This is the minimum required in Analytics version 3.0.0 and above to ensure the events with the push notification data are sent correctly.
// In a real game you would need to handle privacy consent states here, see the Analytics documentation for more details.
await Events.CheckForRequiredConsents();
await AnalyticsService.Instance.CheckForRequiredConsents();

try
{
string pushToken = await PushNotificationService.Instance.RegisterForPushNotificationsAsync();

PushNotificationService.Instance..OnNotificationReceived += notificationData =>
PushNotificationService.Instance.OnNotificationReceived += notificationData =>
{
Debug.Log("Received a notification!");
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,51 @@
using UnityEditor.Android;
using UnityEngine;

namespace Editor
namespace Unity.Services.PushNotifications.Editor
{
public class InsertPushNotificationDependenciesIntoGradleScript: IPostGenerateGradleAndroidProject
public class InsertPushNotificationDependenciesIntoGradleScript : IPostGenerateGradleAndroidProject
{
public int callbackOrder => 0;

const string k_GradleDependencyOpeningTag = "dependencies {";

readonly Dictionary<string, string> m_Dependencies = new Dictionary<string, string>
{
{"com.google.firebase:firebase-messaging-ktx", "22.0.0"}
};

public void OnPostGenerateGradleAndroidProject(string path)
{
string libraryBuildGradlePath = Path.Combine(path, "build.gradle");
string buildGradleFileContent = File.ReadAllText(libraryBuildGradlePath);

string dependencyString = "";

foreach (var keyValuePair in m_Dependencies)
{
string library = keyValuePair.Key;
string version = keyValuePair.Value;

if (!buildGradleFileContent.Contains(library))
{
dependencyString = $"{dependencyString} implementation '{library}:{version}'\n";
}
}

string updatedBuildGradleFileContent = buildGradleFileContent.Replace(k_GradleDependencyOpeningTag, $"{k_GradleDependencyOpeningTag}\n{dependencyString}");
File.WriteAllText(libraryBuildGradlePath, updatedBuildGradleFileContent);

#if UNITY_2020_1_OR_NEWER
string projectRoot = path.Substring(0, path.LastIndexOf(Path.DirectorySeparatorChar));
string gradlePropertiesFilePath = Path.Combine(projectRoot, "gradle.properties");

string gradlePropertiesFileContent = File.Exists(gradlePropertiesFilePath) ? File.ReadAllText(gradlePropertiesFilePath) : "";

string updatedPropertiesFileContent = gradlePropertiesFileContent;
if (!gradlePropertiesFileContent.Contains("android.useAndroidX="))
{
updatedPropertiesFileContent = $"{gradlePropertiesFileContent}\nandroid.useAndroidX=true";
}
}
else if (gradlePropertiesFileContent.Contains("android.useAndroidX=false"))
{
Debug.LogWarning("The Unity Push Notifications SDK requires androidx support. We've updated your gradle.properties file to enable androidX, check this is appropriate for your use case.");
Expand Down
6 changes: 3 additions & 3 deletions Editor/Settings/PushNotificationEditorGameService.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using Unity.Services.Core.Editor;
using UnityEditor;

namespace Editor.Settings
namespace Unity.Services.PushNotifications.Editor
{
public struct PushNotificationIdentifier : IEditorGameServiceIdentifier
{
public string GetKey() => "Push Notifications";
}
public class PushNotificationEditorGameService: IEditorGameService

public class PushNotificationEditorGameService : IEditorGameService
{
static readonly PushNotificationIdentifier k_Identifier = new PushNotificationIdentifier();

Expand Down
24 changes: 12 additions & 12 deletions Editor/Settings/PushSettingsProvider.cs
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@
using System.Collections.Generic;
using Editor.Settings;
using Unity.Services.Core.Editor;
using UnityEditor;
using UnityEngine.UIElements;

namespace Unity.Services.PushNotifications.Editor
{
public class PushSettingsProvider: EditorGameServiceSettingsProvider
public class PushSettingsProvider : EditorGameServiceSettingsProvider
{
const string k_Title = "Push Notifications";
const string k_Title = "Push Notifications";

protected override IEditorGameService EditorGameService => k_GameService;
protected override string Title => k_Title;
protected override string Description => "This package adds support for Push Notifications to your game. It allows sending rich push notifications with images, and provides analytics on the number of received push notifications.";

static readonly PushNotificationEditorGameService k_GameService = new PushNotificationEditorGameService();

PushSettingsProvider(SettingsScope scopes, IEnumerable<string> keywords = null)
: base(GenerateProjectSettingsPath(k_Title), scopes, keywords) { }
: base(GenerateProjectSettingsPath(k_Title), scopes, keywords) {}

protected override VisualElement GenerateServiceDetailUI()
{
SerializedObject serializedSettings = GetSerializedSettings();

VisualElement containerVisualElement = new VisualElement();

Label headerLabel = new Label("Android");
headerLabel.style.fontSize = 14;
headerLabel.style.unityFontStyleAndWeight = UnityEngine.FontStyle.Bold;
headerLabel.style.marginLeft = 4;
containerVisualElement.Add(headerLabel);

CreateFormRow("API Key", nameof(PushNotificationSettings.androidApiKey), serializedSettings, containerVisualElement);
CreateFormRow("Sender ID", nameof(PushNotificationSettings.androidSenderId), serializedSettings, containerVisualElement);
CreateFormRow("Application ID", nameof(PushNotificationSettings.androidApplicationId), serializedSettings, containerVisualElement);
CreateFormRow("Project ID", nameof(PushNotificationSettings.androidProjectId), serializedSettings, containerVisualElement);

return containerVisualElement;
}

Expand Down Expand Up @@ -67,7 +66,8 @@ static void CreateFormRow(string title, string fieldName, SerializedObject setti
textField.RegisterValueChangedCallback(delegate(ChangeEvent<string> evt)
{
settings.FindProperty(fieldName).stringValue = evt.newValue;
if (settings.ApplyModifiedProperties()) {
if (settings.ApplyModifiedProperties())
{
AssetDatabase.SaveAssets();
}
});
Expand All @@ -77,7 +77,7 @@ static void CreateFormRow(string title, string fieldName, SerializedObject setti
container.Add(rowContainer);
}

static SerializedObject GetSerializedSettings()
static SerializedObject GetSerializedSettings()
{
PushNotificationSettings cfg = AssetDatabase.LoadAssetAtPath<PushNotificationSettings>(PushNotificationSettings.fullAssetPath);

Expand Down
8 changes: 1 addition & 7 deletions Editor/Unity.Services.PushNotifications.Editor.api
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
// This file is generated. Do not modify by hand.
// XML documentation file not found. To check if public methods have XML comments,
// make sure the XML doc file is present and located next to the scraped dll
namespace Editor
namespace Unity.Services.PushNotifications.Editor
{
public class InsertPushNotificationDependenciesIntoGradleScript : UnityEditor.Android.IPostGenerateGradleAndroidProject, UnityEditor.Build.IOrderedCallback
{
public virtual int callbackOrder { get; }
public InsertPushNotificationDependenciesIntoGradleScript() {}
public virtual void OnPostGenerateGradleAndroidProject(string path);
}
}

namespace Editor.Settings
{
public class PushNotificationEditorGameService : Unity.Services.Core.Editor.IEditorGameService
{
public virtual Unity.Services.Core.Editor.IEditorGameServiceEnabler Enabler { get; }
Expand All @@ -28,10 +25,7 @@ namespace Editor.Settings
{
public virtual string GetKey();
}
}

namespace Unity.Services.PushNotifications.Editor
{
public class PushSettingsProvider : Unity.Services.Core.Editor.EditorGameServiceSettingsProvider
{
protected virtual string Description { get; }
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Analytics/PushNotificationAnalytics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Unity.Services.PushNotifications
static class SdkVersion
{
// This value should always match what is in the package.json for this package
public static readonly string SDK_VERSION = "2.0.0-pre.1";
public static readonly string SDK_VERSION = "2.0.0-pre.2";
}

interface IPushNotificationsAnalytics
Expand Down
2 changes: 1 addition & 1 deletion ValidationExceptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"ValidationTest": "API Validation",
"ExceptionMessage": "Breaking changes require a new major version.",
"PackageVersion": "1.1.0-pre.2"
"PackageVersion": "2.0.0-pre.2"
}
],
"WarningExceptions": []
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.unity.services.push-notifications",
"displayName": "Push Notifications",
"version": "2.0.0-pre.1",
"version": "2.0.0-pre.2",
"unity": "2020.3",
"description": "This package adds support for Push Notifications to your game. It allows sending rich push notifications with images, and provides analytics on the number of received push notifications.",
"dependencies": {
Expand All @@ -16,14 +16,14 @@
}
],
"_upm": {
"changelog": "### Fixed\n\n* Android plugin now uses a named Firebase instance to avoid clashing with any default instances already in the project."
"changelog": "### Fixed\n\n* Fixed a documentation bug\n* Fixed a compile issue that could occur if custom Editor classes were added to a Unity project"
},
"upmCi": {
"footprint": "847b090baf556a3ed552e0a124fe676a17feb0a1"
"footprint": "1409906e5289dfc4474b663304f308e2e8273672"
},
"repository": {
"url": "https://github.cds.internal.unity3d.com/unity/operate-services-sdk.git",
"type": "git",
"revision": "26dbbb1ee0f91943208de063bb287e35881fb19c"
"revision": "7f13c78fe742bdc29ae7884480c462f42b9d8c31"
}
}

0 comments on commit 72d9171

Please sign in to comment.