diff --git a/com.unity.mobile.notifications/Documentation~/Android.md b/com.unity.mobile.notifications/Documentation~/Android.md index 7a1abc9f..c4141bc2 100644 --- a/com.unity.mobile.notifications/Documentation~/Android.md +++ b/com.unity.mobile.notifications/Documentation~/Android.md @@ -6,23 +6,7 @@ Starting in Android 8.0, all notifications must be assigned to a notification ch Notification channels can be grouped together. This is not required, but it may look better in the Settings UI. -```c# -var group = new AndroidNotificationChannelGroup() -{ - Id = "Main", - Name = "Main notifications", -}; -AndroidNotificationCenter.RegisterNotificationChannelGroup(group); -var channel = new AndroidNotificationChannel() -{ - Id = "channel_id", - Name = "Default Channel", - Importance = Importance.Default, - Description = "Generic notifications", - Group = "Main", // must be same as Id of previously registered group -}; -AndroidNotificationCenter.RegisterNotificationChannel(channel); -``` +[!code-cs[](../Tests/Editor/DocCodeSamples/ManageNotificationChannels.cs)] For details about other properties you can set, see [AndroidNotificationChannel](../api/Unity.Notifications.Android.AndroidNotificationChannel.html). diff --git a/com.unity.mobile.notifications/Tests/Editor/DocCodeSamples.meta b/com.unity.mobile.notifications/Tests/Editor/DocCodeSamples.meta new file mode 100644 index 00000000..8fb246ff --- /dev/null +++ b/com.unity.mobile.notifications/Tests/Editor/DocCodeSamples.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2fee4dbf6ca204cd287f2bf9515a0f2d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.mobile.notifications/Tests/Editor/DocCodeSamples/ManageNotificationChannels.cs b/com.unity.mobile.notifications/Tests/Editor/DocCodeSamples/ManageNotificationChannels.cs new file mode 100644 index 00000000..f1c54bcd --- /dev/null +++ b/com.unity.mobile.notifications/Tests/Editor/DocCodeSamples/ManageNotificationChannels.cs @@ -0,0 +1,24 @@ +using Unity.Notifications.Android; +using UnityEngine; + +public class ManageNotificationChannels: MonoBehaviour +{ + var group = new AndroidNotificationChannelGroup() + { + Id = "Main", + Name = "Main notifications", + }; + + AndroidNotificationCenter.RegisterNotificationChannelGroup(group); + + var channel = new AndroidNotificationChannel() + { + Id = "channel_id", + Name = "Default Channel", + Importance = Importance.Default, + Description = "Generic notifications", + Group = "Main", // must be same as Id of previously registered group + }; + + AndroidNotificationCenter.RegisterNotificationChannel(channel); +} \ No newline at end of file diff --git a/com.unity.mobile.notifications/Tests/Editor/DocCodeSamples/ManageNotificationChannels.cs.meta b/com.unity.mobile.notifications/Tests/Editor/DocCodeSamples/ManageNotificationChannels.cs.meta new file mode 100644 index 00000000..16cef3ab --- /dev/null +++ b/com.unity.mobile.notifications/Tests/Editor/DocCodeSamples/ManageNotificationChannels.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: ee53b1978f2f04accbb37d195d296c1c \ No newline at end of file diff --git a/com.unity.mobile.notifications/Tests/Editor/DocCodeSamples/Unity.com.unity.mobile.notifications.DocCodeSamples.Editor.Tests.asmdef b/com.unity.mobile.notifications/Tests/Editor/DocCodeSamples/Unity.com.unity.mobile.notifications.DocCodeSamples.Editor.Tests.asmdef new file mode 100644 index 00000000..f25c4d54 --- /dev/null +++ b/com.unity.mobile.notifications/Tests/Editor/DocCodeSamples/Unity.com.unity.mobile.notifications.DocCodeSamples.Editor.Tests.asmdef @@ -0,0 +1,22 @@ +{ + "name": "NewAssembly", + "rootNamespace": "", + "references": [ + "GUID:d6bcb02e32b9c47c8a8a5af0676695d5" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [ + "nunit.framework.dll" + ], + "autoReferenced": false, + "defineConstraints": [ + "UNITY_INCLUDE_TESTS" + ], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/com.unity.mobile.notifications/Tests/Editor/DocCodeSamples/Unity.com.unity.mobile.notifications.DocCodeSamples.Editor.Tests.asmdef.meta b/com.unity.mobile.notifications/Tests/Editor/DocCodeSamples/Unity.com.unity.mobile.notifications.DocCodeSamples.Editor.Tests.asmdef.meta new file mode 100644 index 00000000..f3906955 --- /dev/null +++ b/com.unity.mobile.notifications/Tests/Editor/DocCodeSamples/Unity.com.unity.mobile.notifications.DocCodeSamples.Editor.Tests.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d2136e2c4670f41408aecbd4ebdbae50 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: