Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @OneSignal/eng-sdk-platform
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ The only thing remaining is to setup your own notification icons. You can do thi
with your own. There is a complete guide for this [in the plugin's README](com.onesignal.unity.android/Editor/OneSignalConfig.androidlib/README.md). See our
[Customize Notification Icons](https://documentation.onesignal.com/docs/customize-notification-icons) page for additional details.

### Disable Location Module
### Disable Location Module (Optional)

By default, the OneSignal Unity SDK includes OneSignal's native location module so `OneSignal.Location` works without extra setup. If your app does not use location features, you can exclude the native location module from iOS and Android builds. There are two ways to opt out:

- **Editor toggle** (interactive): select **OneSignal > Disable Location Module** in the Unity Editor before resolving Android dependencies or building iOS. This is persisted per project in `ProjectSettings/OneSignalSettings.json`.
- **Editor toggle** (interactive): enable **Project Settings > OneSignal > Disable Location Module** in the Unity Editor before resolving Android dependencies or building iOS. This is persisted per project in `ProjectSettings/OneSignalSettings.json`.
- **Environment variable** (CLI/CI): set `ONESIGNAL_DISABLE_LOCATION=true` (or `1`) in the environment before launching Unity, for example:

```sh
Expand Down
2 changes: 1 addition & 1 deletion com.onesignal.unity.android/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.onesignal.unity.android",
"displayName": "OneSignal Unity SDK - Android",
"version": "5.2.11",
"unity": "2018.4",
"unity": "2021.3",
"description": "OneSignal is the market leader in customer engagement, powering mobile push, web push, email, and in-app messages.",
"dependencies": {
"com.onesignal.unity.core": "5.2.11"
Expand Down
13 changes: 0 additions & 13 deletions com.onesignal.unity.core/Editor/OneSignalSDKSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,6 @@ public static void Save()
File.WriteAllText(_settingsPath, JsonUtility.ToJson(_settings, true));
}

[MenuItem("OneSignal/Disable Location Module")]
private static void ToggleDisableLocation()
{
DisableLocation = !DisableLocation;
}

[MenuItem("OneSignal/Disable Location Module", true)]
private static bool ToggleDisableLocationValidate()
{
Menu.SetChecked("OneSignal/Disable Location Module", DisableLocation);
return true;
}

private static readonly string _settingsPath = Path.Combine(
"ProjectSettings",
"OneSignalSettings.json"
Expand Down
115 changes: 115 additions & 0 deletions com.onesignal.unity.core/Editor/OneSignalSettingsProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*
* Modified MIT License
*
* Copyright 2023 OneSignal
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* 1. The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 2. All copies of substantial portions of the Software may only be used in connection
* with services provided by OneSignal.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

namespace OneSignalSDK
{
/// <summary>
/// Adds a "OneSignal" page under Project Settings for persistent SDK configuration.
/// </summary>
public static class OneSignalSettingsProvider
{
private const string _path = "Project/OneSignal";
private const float _contentPadding = 10f;

[SettingsProvider]
public static SettingsProvider Create()
{
var keywords = new HashSet<string>(
new[] { "OneSignal", "Push", "Notifications", "Location", "Disable Location" }
);

return new SettingsProvider(_path, SettingsScope.Project)
{
label = "OneSignal",
keywords = keywords,
guiHandler = _ => DrawGUI(),
};
}

private static void DrawGUI()
{
var environmentOverride = Environment.GetEnvironmentVariable(
OneSignalSDKSettings.DisableLocationEnvVar
);
var hasEnvironmentOverride = !string.IsNullOrEmpty(environmentOverride);

EditorGUILayout.BeginHorizontal();
GUILayout.Space(_contentPadding);
EditorGUILayout.BeginVertical();

EditorGUILayout.Space();

EditorGUILayout.LabelField("Location", EditorStyles.boldLabel);

using (new EditorGUI.DisabledScope(hasEnvironmentOverride))
{
var newValue = EditorGUILayout.ToggleLeft(
new GUIContent(
"Disable Location Module",
"Excludes the OneSignal location dependency from the generated native "
+ "build. Enable this if your app does not use location features."
),
OneSignalSDKSettings.DisableLocation
);

if (newValue != OneSignalSDKSettings.DisableLocation)
OneSignalSDKSettings.DisableLocation = newValue;
}

EditorGUILayout.Space();

if (hasEnvironmentOverride)
{
EditorGUILayout.HelpBox(
$"The {OneSignalSDKSettings.DisableLocationEnvVar} environment variable is set "
+ $"to \"{environmentOverride}\" and overrides this setting for the current "
+ "session. The effective value is "
+ $"{(OneSignalSDKSettings.EffectiveDisableLocation ? "disabled" : "enabled")}.",
MessageType.Info
);
}
else
{
EditorGUILayout.HelpBox(
$"Set the {OneSignalSDKSettings.DisableLocationEnvVar} environment variable "
+ "(\"true\" or \"1\") to override this setting for CLI and CI builds "
+ "without modifying project settings.",
MessageType.None
);
}

EditorGUILayout.EndVertical();
GUILayout.Space(_contentPadding);
EditorGUILayout.EndHorizontal();
}
}
}

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

6 changes: 5 additions & 1 deletion com.onesignal.unity.core/Editor/Platform/UserManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ public string ExternalId
get => null;
}

public event EventHandler<UserStateChangedEventArgs> Changed;
public event EventHandler<UserStateChangedEventArgs> Changed
{
add { }
remove { }
}

private PushSubscription _subscription = new PushSubscription();

Expand Down
2 changes: 1 addition & 1 deletion com.onesignal.unity.core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.onesignal.unity.core",
"displayName": "OneSignal Unity SDK - Core",
"version": "5.2.11",
"unity": "2018.4",
"unity": "2021.3",
"description": "OneSignal is the market leader in customer engagement, powering mobile push, web push, email, and in-app messages.",
"dependencies": {
},
Expand Down
2 changes: 1 addition & 1 deletion com.onesignal.unity.ios/Editor/BuildPostProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private void AddNotificationServiceExtension()
extensionGuid = _project.AddAppExtension(
_project.GetMainTargetGuid(),
ServiceExtensionTargetName,
PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.iOS)
PlayerSettings.GetApplicationIdentifier(NamedBuildTarget.iOS)
+ "."
+ ServiceExtensionTargetName,
ServiceExtensionTargetName + "/" + "Info.plist" // Unix path as it's used by Xcode
Expand Down
2 changes: 1 addition & 1 deletion com.onesignal.unity.ios/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.onesignal.unity.ios",
"displayName": "OneSignal Unity SDK - iOS",
"version": "5.2.11",
"unity": "2018.4",
"unity": "2021.3",
"description": "OneSignal is the market leader in customer engagement, powering mobile push, web push, email, and in-app messages.",
"dependencies": {
"com.onesignal.unity.core": "5.2.11"
Expand Down

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

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

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Loading