diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e4255b..696e255 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,17 @@ # Change Log -## 4.0.1 (Nov 4, 2024) +## 4.1.0 (Nov 29, 2024) ### Features +- Added `SetPushTriggerOption` to `SendbirdChatClient` +- Added `GetPushTriggerOption` to `SendbirdChatClient` +- Added `SetMyPushTriggerOption` to `SbGroupChannel` +- Added `GetMyPushTriggerOption` to `SbGroupChannel` +- Added `SbPushTriggerOption` +### Bug Fixes +- Fixed an issue with `SendbirdChat.BlockUser` where 'User not found error' occurs due to URL encoding + +## 4.0.1 (Nov 4, 2024) +### Bug Fixes - Fixed an issue where build failed on the Windows platform ## 4.0.0 (Sep 25, 2024) @@ -19,7 +29,7 @@ - Added support for .NET 4.x ## 4.0.0-beta.1 (Sep 15, 2023) -### Improvements +### Bug Fixes - Fixed the bug regarding the URL encoding ## 4.0.0-beta (Aug 25, 2023) diff --git a/Runtime/Scripts/Internal/ChatClient/Channel/BaseChannelExtends/GroupChannel/SbGroupChannel+MyPushTriggerOption.cs b/Runtime/Scripts/Internal/ChatClient/Channel/BaseChannelExtends/GroupChannel/SbGroupChannel+MyPushTriggerOption.cs new file mode 100644 index 0000000..777b67d --- /dev/null +++ b/Runtime/Scripts/Internal/ChatClient/Channel/BaseChannelExtends/GroupChannel/SbGroupChannel+MyPushTriggerOption.cs @@ -0,0 +1,52 @@ +// +// Copyright (c) 2024 Sendbird, Inc. +// + +namespace Sendbird.Chat +{ + public partial class SbGroupChannel + { + private void GetMyPushTriggerOptionInternal(SbGroupChannelGetMyPushTriggerOptionHandler inCompletionHandler) + { + if (inCompletionHandler == null) + return; + + void OnCompletionHandler(ApiCommandAbstract.Response inResponse, SbError inError, bool inIsCanceled) + { + if (inResponse is GetMyPushTriggerOptionApiCommand.Response response) + { + inCompletionHandler.Invoke(response.GroupChannelPushTriggerOption, inError); + return; + } + + inCompletionHandler.Invoke(inMyPushTriggerOption: null, inError); + } + + GetMyPushTriggerOptionApiCommand.Request apiCommand = new GetMyPushTriggerOptionApiCommand.Request( + chatMainContextRef.CurrentUserId, Url, OnCompletionHandler); + + chatMainContextRef.CommandRouter.RequestApiCommand(apiCommand); + } + + private void SetMyPushTriggerOptionInternal(SbGroupChannelPushTriggerOption inGroupChannelPushTriggerOption, SbErrorHandler inCompletionHandler) + { + if (inCompletionHandler == null) + return; + + void OnCompletionHandler(ApiCommandAbstract.Response inResponse, SbError inError, bool inIsCanceled) + { + if (inResponse is SetMyPushTriggerOptionApiCommand.Response response) + { + _myPushTriggerOption = response.GroupChannelPushTriggerOption; + } + + inCompletionHandler.Invoke(inError); + } + + SetMyPushTriggerOptionApiCommand.Request apiCommand = new SetMyPushTriggerOptionApiCommand.Request( + chatMainContextRef.CurrentUserId, Url, inGroupChannelPushTriggerOption, OnCompletionHandler); + + chatMainContextRef.CommandRouter.RequestApiCommand(apiCommand); + } + } +} \ No newline at end of file diff --git a/Runtime/Scripts/Internal/ChatClient/Channel/BaseChannelExtends/GroupChannel/SbGroupChannel+MyPushTriggerOption.cs.meta b/Runtime/Scripts/Internal/ChatClient/Channel/BaseChannelExtends/GroupChannel/SbGroupChannel+MyPushTriggerOption.cs.meta new file mode 100644 index 0000000..8ba4bef --- /dev/null +++ b/Runtime/Scripts/Internal/ChatClient/Channel/BaseChannelExtends/GroupChannel/SbGroupChannel+MyPushTriggerOption.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8f8234dcc4a74802a98c8afb0a6e550a +timeCreated: 1732770064 \ No newline at end of file diff --git a/Runtime/Scripts/Internal/ChatClient/SbGroupChannelPushTriggerOptionExtension.cs b/Runtime/Scripts/Internal/ChatClient/SbGroupChannelPushTriggerOptionExtension.cs new file mode 100644 index 0000000..b1908d4 --- /dev/null +++ b/Runtime/Scripts/Internal/ChatClient/SbGroupChannelPushTriggerOptionExtension.cs @@ -0,0 +1,32 @@ +// +// Copyright (c) 2023 Sendbird, Inc. +// + +using System; + +namespace Sendbird.Chat +{ + internal static class SbPushTriggerOptionExtension + { + private static int _enumCount = 0; + + internal static SbPushTriggerOption? JsonNameToType(string inJsonName) + { + if (string.IsNullOrEmpty(inJsonName) == false) + { + if (_enumCount <= 0) + _enumCount = Enum.GetValues(typeof(SbPushTriggerOption)).Length; + + for (SbPushTriggerOption enumType = 0; enumType < (SbPushTriggerOption)_enumCount; enumType++) + { + if (enumType.ToJsonName().Equals(inJsonName, StringComparison.OrdinalIgnoreCase)) + return enumType; + } + + Logger.Warning(Logger.CategoryType.Command, $"SbPushTriggerOption::ToJsonName Invalid type name:{inJsonName}"); + } + + return null; + } + } +} \ No newline at end of file diff --git a/Runtime/Scripts/Internal/ChatClient/SbGroupChannelPushTriggerOptionExtension.cs.meta b/Runtime/Scripts/Internal/ChatClient/SbGroupChannelPushTriggerOptionExtension.cs.meta new file mode 100644 index 0000000..2b35ee1 --- /dev/null +++ b/Runtime/Scripts/Internal/ChatClient/SbGroupChannelPushTriggerOptionExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8c6b9b72ee5b4fd587ad3c90e522c338 +timeCreated: 1732838338 \ No newline at end of file diff --git a/Runtime/Scripts/Internal/ChatClient/SendbirdChatMain/SendbirdChatMain+Push.cs b/Runtime/Scripts/Internal/ChatClient/SendbirdChatMain/SendbirdChatMain+Push.cs index 954a064..6ec9b30 100644 --- a/Runtime/Scripts/Internal/ChatClient/SendbirdChatMain/SendbirdChatMain+Push.cs +++ b/Runtime/Scripts/Internal/ChatClient/SendbirdChatMain/SendbirdChatMain+Push.cs @@ -55,5 +55,43 @@ internal void GetDoNotDisturb(SbDoNotDisturbHandler inCompletionHandler) { ChatMainContext.PushManager.GetDoNotDisturb(inCompletionHandler); } + + internal void GetPushTriggerOption(SbPushTriggerOptionHandler inCompletionHandler) + { + if (inCompletionHandler == null) + return; + + void OnCompletionHandler(ApiCommandAbstract.Response inResponse, SbError inError, bool inIsCanceled) + { + if (inResponse is GetPushTriggerOptionApiCommand.Response response) + { + inCompletionHandler.Invoke(response.GroupChannelPushTriggerOptionNullable, inError); + return; + } + + inCompletionHandler.Invoke(inPushTriggerOption: null, inError); + } + + GetPushTriggerOptionApiCommand.Request apiCommand = new GetPushTriggerOptionApiCommand.Request( + ChatMainContext.CurrentUserId, OnCompletionHandler); + + ChatMainContext.CommandRouter.RequestApiCommand(apiCommand); + } + + internal void SetPushTriggerOption(SbPushTriggerOption inPushTriggerOption, SbErrorHandler inCompletionHandler) + { + if (inCompletionHandler == null) + return; + + void OnCompletionHandler(ApiCommandAbstract.Response inResponse, SbError inError, bool inIsCanceled) + { + inCompletionHandler.Invoke(inError); + } + + SetPushTriggerOptionApiCommand.Request apiCommand = new SetPushTriggerOptionApiCommand.Request( + ChatMainContext.CurrentUserId, inPushTriggerOption, OnCompletionHandler); + + ChatMainContext.CommandRouter.RequestApiCommand(apiCommand); + } } } \ No newline at end of file diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Channel/GroupChannel/GetMyPushTriggerOptionApiCommand.cs b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Channel/GroupChannel/GetMyPushTriggerOptionApiCommand.cs new file mode 100644 index 0000000..bb4f33a --- /dev/null +++ b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Channel/GroupChannel/GetMyPushTriggerOptionApiCommand.cs @@ -0,0 +1,41 @@ +// +// Copyright (c) 2022 Sendbird, Inc. +// + +using System; +using System.Net; +using Newtonsoft.Json; + +namespace Sendbird.Chat +{ + internal sealed class GetMyPushTriggerOptionApiCommand + { + internal sealed class Request : ApiCommandAbstract.GetRequest + { + internal Request(string inUserId, string inChannelUrl, ResultHandler inResultHandler) + { + string encodedUserId = WebUtility.UrlEncode(inUserId); + string encodedChannelUrl = WebUtility.UrlEncode(inChannelUrl); + Url = $"{USERS_PREFIX_URL}/{encodedUserId}/push_preference/{encodedChannelUrl}"; + ResponseType = typeof(Response); + resultHandler = inResultHandler; + } + } + + [Serializable] + internal sealed class Response : ApiCommandAbstract.Response + { + [JsonProperty("push_trigger_option")] internal readonly string pushTriggerOption; + + internal SbGroupChannelPushTriggerOption? GroupChannelPushTriggerOption { get; private set; } = null; + + internal override void OnResponseAfterDeserialize(string inJsonString) + { + if (string.IsNullOrEmpty(pushTriggerOption) == false) + { + GroupChannelPushTriggerOption = SbGroupChannelPushTriggerOptionExtension.JsonNameToType(pushTriggerOption); + } + } + } + } +} \ No newline at end of file diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Channel/GroupChannel/GetMyPushTriggerOptionApiCommand.cs.meta b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Channel/GroupChannel/GetMyPushTriggerOptionApiCommand.cs.meta new file mode 100644 index 0000000..98d3920 --- /dev/null +++ b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Channel/GroupChannel/GetMyPushTriggerOptionApiCommand.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2ea9e0eca120442a8090d9f02902ead5 +timeCreated: 1732780292 \ No newline at end of file diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Channel/GroupChannel/SetMyPushTriggerOptionApiCommand.cs b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Channel/GroupChannel/SetMyPushTriggerOptionApiCommand.cs new file mode 100644 index 0000000..22bce5d --- /dev/null +++ b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Channel/GroupChannel/SetMyPushTriggerOptionApiCommand.cs @@ -0,0 +1,56 @@ +// +// Copyright (c) 2022 Sendbird, Inc. +// + +using System; +using System.Net; +using Newtonsoft.Json; + +namespace Sendbird.Chat +{ + internal sealed class SetMyPushTriggerOptionApiCommand + { + internal sealed class Request : ApiCommandAbstract.PutRequest + { + [Serializable] + private struct Payload + { +#pragma warning disable CS0649 + [JsonProperty("push_trigger_option")] internal string pushTriggerOption; +#pragma warning restore CS0649 + } + + internal Request(string inUserId, string inChannelUrl, SbGroupChannelPushTriggerOption inGroupChannelPushTriggerOption, ResultHandler inResultHandler) + { + string encodedUserId = WebUtility.UrlEncode(inUserId); + string encodedChannelUrl = WebUtility.UrlEncode(inChannelUrl); + Url = $"{USERS_PREFIX_URL}/{encodedUserId}/push_preference/{encodedChannelUrl}"; + ResponseType = typeof(Response); + resultHandler = inResultHandler; + + Payload tempPayload = new Payload + { + pushTriggerOption = inGroupChannelPushTriggerOption.ToJsonName() + }; + + ContentBody = NewtonsoftJsonExtension.SerializeObjectIgnoreException(tempPayload); + } + } + + [Serializable] + internal sealed class Response : ApiCommandAbstract.Response + { + [JsonProperty("push_trigger_option")] internal readonly string pushTriggerOption; + + internal SbGroupChannelPushTriggerOption GroupChannelPushTriggerOption { get; private set; } + + internal override void OnResponseAfterDeserialize(string inJsonString) + { + if (string.IsNullOrEmpty(pushTriggerOption) == false) + { + GroupChannelPushTriggerOption = SbGroupChannelPushTriggerOptionExtension.JsonNameToType(pushTriggerOption); + } + } + } + } +} \ No newline at end of file diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Channel/GroupChannel/SetMyPushTriggerOptionApiCommand.cs.meta b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Channel/GroupChannel/SetMyPushTriggerOptionApiCommand.cs.meta new file mode 100644 index 0000000..56c9d96 --- /dev/null +++ b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Channel/GroupChannel/SetMyPushTriggerOptionApiCommand.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4893833a982b4aeaa8ba8c42d87bc679 +timeCreated: 1732780597 \ No newline at end of file diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/DoNotDisturb.meta b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/DoNotDisturb.meta new file mode 100644 index 0000000..8a5bb6e --- /dev/null +++ b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/DoNotDisturb.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d74648bfdcdf486c9238f221d0a1fe26 +timeCreated: 1732839477 \ No newline at end of file diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/GetDoNotDisturbApiCommand.cs b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/DoNotDisturb/GetDoNotDisturbApiCommand.cs similarity index 100% rename from Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/GetDoNotDisturbApiCommand.cs rename to Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/DoNotDisturb/GetDoNotDisturbApiCommand.cs diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/GetDoNotDisturbApiCommand.cs.meta b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/DoNotDisturb/GetDoNotDisturbApiCommand.cs.meta similarity index 100% rename from Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/GetDoNotDisturbApiCommand.cs.meta rename to Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/DoNotDisturb/GetDoNotDisturbApiCommand.cs.meta diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/SetDoNotDisturbApiCommand.cs b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/DoNotDisturb/SetDoNotDisturbApiCommand.cs similarity index 100% rename from Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/SetDoNotDisturbApiCommand.cs rename to Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/DoNotDisturb/SetDoNotDisturbApiCommand.cs diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/SetDoNotDisturbApiCommand.cs.meta b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/DoNotDisturb/SetDoNotDisturbApiCommand.cs.meta similarity index 100% rename from Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/SetDoNotDisturbApiCommand.cs.meta rename to Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/DoNotDisturb/SetDoNotDisturbApiCommand.cs.meta diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTemplate.meta b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTemplate.meta new file mode 100644 index 0000000..3c09907 --- /dev/null +++ b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTemplate.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5069baf041c848e292fc18c3b61b5053 +timeCreated: 1732839494 \ No newline at end of file diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/GetPushTemplateApiCommand.cs b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTemplate/GetPushTemplateApiCommand.cs similarity index 100% rename from Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/GetPushTemplateApiCommand.cs rename to Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTemplate/GetPushTemplateApiCommand.cs diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/GetPushTemplateApiCommand.cs.meta b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTemplate/GetPushTemplateApiCommand.cs.meta similarity index 100% rename from Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/GetPushTemplateApiCommand.cs.meta rename to Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTemplate/GetPushTemplateApiCommand.cs.meta diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/SetPushTemplateApiCommand.cs b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTemplate/SetPushTemplateApiCommand.cs similarity index 100% rename from Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/SetPushTemplateApiCommand.cs rename to Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTemplate/SetPushTemplateApiCommand.cs diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/SetPushTemplateApiCommand.cs.meta b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTemplate/SetPushTemplateApiCommand.cs.meta similarity index 100% rename from Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/SetPushTemplateApiCommand.cs.meta rename to Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTemplate/SetPushTemplateApiCommand.cs.meta diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushToken.meta b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushToken.meta new file mode 100644 index 0000000..6da05de --- /dev/null +++ b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushToken.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 64705cdb277940579978ecf4dabee398 +timeCreated: 1732839527 \ No newline at end of file diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/GetPushTokensApiCommand.cs b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushToken/GetPushTokensApiCommand.cs similarity index 100% rename from Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/GetPushTokensApiCommand.cs rename to Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushToken/GetPushTokensApiCommand.cs diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/GetPushTokensApiCommand.cs.meta b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushToken/GetPushTokensApiCommand.cs.meta similarity index 100% rename from Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/GetPushTokensApiCommand.cs.meta rename to Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushToken/GetPushTokensApiCommand.cs.meta diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/RegisterPushTokenApiCommand.cs b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushToken/RegisterPushTokenApiCommand.cs similarity index 100% rename from Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/RegisterPushTokenApiCommand.cs rename to Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushToken/RegisterPushTokenApiCommand.cs diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/RegisterPushTokenApiCommand.cs.meta b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushToken/RegisterPushTokenApiCommand.cs.meta similarity index 100% rename from Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/RegisterPushTokenApiCommand.cs.meta rename to Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushToken/RegisterPushTokenApiCommand.cs.meta diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/UnregisterAllPushTokenApiCommand.cs b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushToken/UnregisterAllPushTokenApiCommand.cs similarity index 100% rename from Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/UnregisterAllPushTokenApiCommand.cs rename to Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushToken/UnregisterAllPushTokenApiCommand.cs diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/UnregisterAllPushTokenApiCommand.cs.meta b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushToken/UnregisterAllPushTokenApiCommand.cs.meta similarity index 100% rename from Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/UnregisterAllPushTokenApiCommand.cs.meta rename to Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushToken/UnregisterAllPushTokenApiCommand.cs.meta diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/UnregisterPushTokenApiCommand.cs b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushToken/UnregisterPushTokenApiCommand.cs similarity index 100% rename from Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/UnregisterPushTokenApiCommand.cs rename to Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushToken/UnregisterPushTokenApiCommand.cs diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/UnregisterPushTokenApiCommand.cs.meta b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushToken/UnregisterPushTokenApiCommand.cs.meta similarity index 100% rename from Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/UnregisterPushTokenApiCommand.cs.meta rename to Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushToken/UnregisterPushTokenApiCommand.cs.meta diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTriggerOption.meta b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTriggerOption.meta new file mode 100644 index 0000000..3e2bc85 --- /dev/null +++ b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTriggerOption.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 46411bb102bb44339828985d31a62563 +timeCreated: 1732839447 \ No newline at end of file diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTriggerOption/GetPushTriggerOptionApiCommand.cs b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTriggerOption/GetPushTriggerOptionApiCommand.cs new file mode 100644 index 0000000..7be8472 --- /dev/null +++ b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTriggerOption/GetPushTriggerOptionApiCommand.cs @@ -0,0 +1,40 @@ +// +// Copyright (c) 2022 Sendbird, Inc. +// + +using System; +using System.Net; +using Newtonsoft.Json; + +namespace Sendbird.Chat +{ + internal sealed class GetPushTriggerOptionApiCommand + { + internal sealed class Request : ApiCommandAbstract.GetRequest + { + internal Request(string inUserId, ResultHandler inResultHandler) + { + string encodedUserId = WebUtility.UrlEncode(inUserId); + Url = $"{USERS_PREFIX_URL}/{encodedUserId}/push_preference"; + ResponseType = typeof(Response); + resultHandler = inResultHandler; + } + } + + [Serializable] + internal sealed class Response : ApiCommandAbstract.Response + { + [JsonProperty("push_trigger_option")] internal readonly string pushTriggerOption; + + internal SbPushTriggerOption? GroupChannelPushTriggerOptionNullable { get; private set; } = null; + + internal override void OnResponseAfterDeserialize(string inJsonString) + { + if (string.IsNullOrEmpty(pushTriggerOption) == false) + { + GroupChannelPushTriggerOptionNullable = SbPushTriggerOptionExtension.JsonNameToType(pushTriggerOption); + } + } + } + } +} \ No newline at end of file diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTriggerOption/GetPushTriggerOptionApiCommand.cs.meta b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTriggerOption/GetPushTriggerOptionApiCommand.cs.meta new file mode 100644 index 0000000..995cf73 --- /dev/null +++ b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTriggerOption/GetPushTriggerOptionApiCommand.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6a402fadd0f64f2595570f53a1b1cac0 +timeCreated: 1732790115 \ No newline at end of file diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTriggerOption/SetPushTriggerOptionApiCommand.cs b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTriggerOption/SetPushTriggerOptionApiCommand.cs new file mode 100644 index 0000000..ec0077b --- /dev/null +++ b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTriggerOption/SetPushTriggerOptionApiCommand.cs @@ -0,0 +1,45 @@ +// +// Copyright (c) 2022 Sendbird, Inc. +// + +using System; +using System.Net; +using Newtonsoft.Json; + +namespace Sendbird.Chat +{ + internal sealed class SetPushTriggerOptionApiCommand + { + internal sealed class Request : ApiCommandAbstract.PutRequest + { + [Serializable] + private struct Payload + { +#pragma warning disable CS0649 + [JsonProperty("push_trigger_option")] internal string pushTriggerOption; +#pragma warning restore CS0649 + } + + internal Request(string inUserId, SbPushTriggerOption inPushTriggerOption, ResultHandler inResultHandler) + { + string encodedUserId = WebUtility.UrlEncode(inUserId); + Url = $"{USERS_PREFIX_URL}/{encodedUserId}/push_preference"; + ResponseType = typeof(Response); + resultHandler = inResultHandler; + + Payload tempPayload = new Payload + { + pushTriggerOption = inPushTriggerOption.ToJsonName() + }; + + ContentBody = NewtonsoftJsonExtension.SerializeObjectIgnoreException(tempPayload); + } + } + + [Serializable] + internal sealed class Response : ApiCommandAbstract.Response + { + [JsonProperty("push_trigger_option")] internal readonly string pushTriggerOption; + } + } +} \ No newline at end of file diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTriggerOption/SetPushTriggerOptionApiCommand.cs.meta b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTriggerOption/SetPushTriggerOptionApiCommand.cs.meta new file mode 100644 index 0000000..f30cc46 --- /dev/null +++ b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/PushTriggerOption/SetPushTriggerOptionApiCommand.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 12aaa2b7217a4c92b60ffc14fa022a4a +timeCreated: 1732790115 \ No newline at end of file diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/SnoozePeriod.meta b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/SnoozePeriod.meta new file mode 100644 index 0000000..7939a55 --- /dev/null +++ b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/SnoozePeriod.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c570a801b4b5436da4e66c3a77751683 +timeCreated: 1732839466 \ No newline at end of file diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/GetSnoozePeriodApiCommand.cs b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/SnoozePeriod/GetSnoozePeriodApiCommand.cs similarity index 100% rename from Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/GetSnoozePeriodApiCommand.cs rename to Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/SnoozePeriod/GetSnoozePeriodApiCommand.cs diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/GetSnoozePeriodApiCommand.cs.meta b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/SnoozePeriod/GetSnoozePeriodApiCommand.cs.meta similarity index 100% rename from Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/GetSnoozePeriodApiCommand.cs.meta rename to Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/SnoozePeriod/GetSnoozePeriodApiCommand.cs.meta diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/SetSnoozePeriodApiCommand.cs b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/SnoozePeriod/SetSnoozePeriodApiCommand.cs similarity index 100% rename from Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/SetSnoozePeriodApiCommand.cs rename to Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/SnoozePeriod/SetSnoozePeriodApiCommand.cs diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/SetSnoozePeriodApiCommand.cs.meta b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/SnoozePeriod/SetSnoozePeriodApiCommand.cs.meta similarity index 100% rename from Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/SetSnoozePeriodApiCommand.cs.meta rename to Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/Push/SnoozePeriod/SetSnoozePeriodApiCommand.cs.meta diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/User/BlockedUserListQueryApiCommand.cs b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/User/BlockedUserListQueryApiCommand.cs index f91dbc5..0d127dd 100644 --- a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/User/BlockedUserListQueryApiCommand.cs +++ b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/User/BlockedUserListQueryApiCommand.cs @@ -15,8 +15,8 @@ internal sealed class Request : ApiCommandAbstract.GetRequest { internal Request(string inToken, int inLimit, string inUserId, List inUserIds, ResultHandler inResultHandler) { - inUserId = WebUtility.UrlEncode(inUserId); - Url = $"{USERS_PREFIX_URL}/{inUserId}/block"; + string encodedUserId = WebUtility.UrlEncode(inUserId); + Url = $"{USERS_PREFIX_URL}/{encodedUserId}/block"; ResponseType = typeof(Response); resultHandler = inResultHandler; diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/User/Moderation/BlockUserApiCommand.cs b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/User/Moderation/BlockUserApiCommand.cs index 1ec85e7..0078d32 100644 --- a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/User/Moderation/BlockUserApiCommand.cs +++ b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/User/Moderation/BlockUserApiCommand.cs @@ -22,9 +22,8 @@ private struct Payload internal Request(string inBlockerUserId, string inTargetUserId, ResultHandler inResultHandler) { - inBlockerUserId = WebUtility.UrlEncode(inBlockerUserId); - inTargetUserId = WebUtility.UrlEncode(inTargetUserId); - Url = $"{USERS_PREFIX_URL}/{inBlockerUserId}/block"; + string encodedBlockerUserId = WebUtility.UrlEncode(inBlockerUserId); + Url = $"{USERS_PREFIX_URL}/{encodedBlockerUserId}/block"; resultHandler = inResultHandler; ResponseType = typeof(Response); diff --git a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/User/Moderation/UnblockUserApiCommand.cs b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/User/Moderation/UnblockUserApiCommand.cs index 24e6f83..91a23bc 100644 --- a/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/User/Moderation/UnblockUserApiCommand.cs +++ b/Runtime/Scripts/Internal/Command/ApiCommand/ApiCommandExtends/User/Moderation/UnblockUserApiCommand.cs @@ -2,9 +2,7 @@ // Copyright (c) 2022 Sendbird, Inc. // -using System; using System.Net; -using Newtonsoft.Json; namespace Sendbird.Chat { @@ -14,9 +12,9 @@ internal sealed class Request : ApiCommandAbstract.DeleteRequest { internal Request(string inBlockerUserId, string inTargetUserId, ResultHandler inResultHandler) { - inBlockerUserId = WebUtility.UrlEncode(inBlockerUserId); - inTargetUserId = WebUtility.UrlEncode(inTargetUserId); - Url = $"{USERS_PREFIX_URL}/{inBlockerUserId}/block/{inTargetUserId}"; + string encodedBlockerUserId = WebUtility.UrlEncode(inBlockerUserId); + string encodedTargetUserId = WebUtility.UrlEncode(inTargetUserId); + Url = $"{USERS_PREFIX_URL}/{encodedBlockerUserId}/block/{encodedTargetUserId}"; resultHandler = inResultHandler; } diff --git a/Runtime/Scripts/Public/ChatClient/Channel/BaseChannelExtends/GroupChannel/SbGroupChannel.cs b/Runtime/Scripts/Public/ChatClient/Channel/BaseChannelExtends/GroupChannel/SbGroupChannel.cs index 19a9c28..c7f6bd5 100644 --- a/Runtime/Scripts/Public/ChatClient/Channel/BaseChannelExtends/GroupChannel/SbGroupChannel.cs +++ b/Runtime/Scripts/Public/ChatClient/Channel/BaseChannelExtends/GroupChannel/SbGroupChannel.cs @@ -475,5 +475,29 @@ public SbMessageCollection CreateMessageCollection(SbMessageCollectionCreatePara { return CreateMessageCollectionInternal(inParams); } + + /// + /// Requests a setting that decides which push notification for the current user to receive in the group channel. + /// + /// + /// + /// @since 4.1.0 + public void GetMyPushTriggerOption(SbGroupChannelGetMyPushTriggerOptionHandler inCompletionHandler) + { + GetMyPushTriggerOptionInternal(inCompletionHandler); + } + + /// + /// Changes a setting that decides which push notification for the current user to receive in the group channel. + /// If a value of option is .Default, a push trigger option in this group channel follows a push trigger option of the current user. It is related with SendbirdChat SetPushTriggerOption. + /// + /// + /// + /// + /// @since 4.1.0 + public void SetMyPushTriggerOption(SbGroupChannelPushTriggerOption inGroupChannelPushTriggerOption, SbErrorHandler inCompletionHandler) + { + SetMyPushTriggerOptionInternal(inGroupChannelPushTriggerOption, inCompletionHandler); + } } } \ No newline at end of file diff --git a/Runtime/Scripts/Public/ChatClient/ISendbirdChatClient.cs b/Runtime/Scripts/Public/ChatClient/ISendbirdChatClient.cs index 36600a4..b314c86 100644 --- a/Runtime/Scripts/Public/ChatClient/ISendbirdChatClient.cs +++ b/Runtime/Scripts/Public/ChatClient/ISendbirdChatClient.cs @@ -328,5 +328,20 @@ public interface ISendbirdChatClient /// /// @since 4.0.0 void GetDoNotDisturb(SbDoNotDisturbHandler inCompletionHandler); + + /// + /// Requests a setting that decides which push notification for the current user to receive in all the group channel. + /// + /// + /// @since 4.1.0 + void GetPushTriggerOption(SbPushTriggerOptionHandler inCompletionHandler); + + /// + /// Changes a setting that decides which push notification for the current user to receive in all the group channel. + /// + /// + /// + /// /// @since 4.1.0 + void SetPushTriggerOption(SbPushTriggerOption inPushTriggerOption, SbErrorHandler inCompletionHandler); } } \ No newline at end of file diff --git a/Runtime/Scripts/Public/ChatClient/Push/SbPushTriggerOption.cs b/Runtime/Scripts/Public/ChatClient/Push/SbPushTriggerOption.cs new file mode 100644 index 0000000..b914346 --- /dev/null +++ b/Runtime/Scripts/Public/ChatClient/Push/SbPushTriggerOption.cs @@ -0,0 +1,31 @@ +// +// Copyright (c) 2024 Sendbird, Inc. +// + +namespace Sendbird.Chat +{ + /// + /// The options to choose which push notification for the current user to receive. + /// + /// @since 4.1.0 + public enum SbPushTriggerOption + { + /// + /// Receive all of remote push notification. + /// + /// @since 4.1.0 + [JsonName("all")] All, + + /// + /// Do NOT receive any remote push notification. + /// + /// @since 4.1.0 + [JsonName("off")] Off, + + /// + /// Receive only mentioned messages’s notification. + /// + /// @since 4.1.0 + [JsonName("mention_only")] MentionOnly + } +} \ No newline at end of file diff --git a/Runtime/Scripts/Public/ChatClient/Push/SbPushTriggerOption.cs.meta b/Runtime/Scripts/Public/ChatClient/Push/SbPushTriggerOption.cs.meta new file mode 100644 index 0000000..1ee5ae6 --- /dev/null +++ b/Runtime/Scripts/Public/ChatClient/Push/SbPushTriggerOption.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 93588b43fc574f3b9361e33d60d7d0f1 +timeCreated: 1732773622 \ No newline at end of file diff --git a/Runtime/Scripts/Public/ChatClient/SbHandlers.cs b/Runtime/Scripts/Public/ChatClient/SbHandlers.cs index 8e05b50..0a8ad35 100644 --- a/Runtime/Scripts/Public/ChatClient/SbHandlers.cs +++ b/Runtime/Scripts/Public/ChatClient/SbHandlers.cs @@ -41,6 +41,9 @@ namespace Sendbird.Chat /// @since 4.0.0 public delegate void SbGroupChannelListHandler(IReadOnlyList inGroupChannels, SbError inError); + + /// @since 4.1.0 + public delegate void SbGroupChannelGetMyPushTriggerOptionHandler(SbGroupChannelPushTriggerOption? inMyPushTriggerOption, SbError inError); /// @since 4.0.0 public delegate void SbMemberListHandler(IReadOnlyList inMembers, SbError inError); @@ -71,6 +74,9 @@ namespace Sendbird.Chat /// @since 4.0.0 public delegate void SbOpenChannelListHandler(IReadOnlyList inOpenChannels, SbError inError); + + /// @since 4.1.0 + public delegate void SbPushTriggerOptionHandler(SbPushTriggerOption? inPushTriggerOption, SbError inError); /// @since 4.0.0 public delegate void SbPushTemplateHandler(string inTemplateName, SbError inError); diff --git a/Runtime/Scripts/Public/ChatClient/SendbirdChatClient.cs b/Runtime/Scripts/Public/ChatClient/SendbirdChatClient.cs index d13c934..14fa665 100644 --- a/Runtime/Scripts/Public/ChatClient/SendbirdChatClient.cs +++ b/Runtime/Scripts/Public/ChatClient/SendbirdChatClient.cs @@ -437,5 +437,26 @@ public void GetDoNotDisturb(SbDoNotDisturbHandler inCompletionHandler) { _sendbirdChatMain.GetDoNotDisturb(inCompletionHandler); } + + /// + /// Requests a setting that decides which push notification for the current user to receive in all the group channel. + /// + /// + /// @since 4.1.0 + public void GetPushTriggerOption(SbPushTriggerOptionHandler inCompletionHandler) + { + _sendbirdChatMain.GetPushTriggerOption(inCompletionHandler); + } + + /// + /// Changes a setting that decides which push notification for the current user to receive in all the group channel. + /// + /// + /// + /// /// @since 4.1.0 + public void SetPushTriggerOption(SbPushTriggerOption inPushTriggerOption, SbErrorHandler inCompletionHandler) + { + _sendbirdChatMain.SetPushTriggerOption(inPushTriggerOption, inCompletionHandler); + } } } \ No newline at end of file diff --git a/Runtime/Scripts/Public/SendbirdChat.cs b/Runtime/Scripts/Public/SendbirdChat.cs index 2260aa3..1351748 100644 --- a/Runtime/Scripts/Public/SendbirdChat.cs +++ b/Runtime/Scripts/Public/SendbirdChat.cs @@ -428,6 +428,27 @@ public static void GetDoNotDisturb(SbDoNotDisturbHandler inCompletionHandler) _sendbirdChatClient.GetDoNotDisturb(inCompletionHandler); } + /// + /// Requests a setting that decides which push notification for the current user to receive in all the group channel. + /// + /// + /// @since 4.1.0 + public static void GetPushTriggerOption(SbPushTriggerOptionHandler inCompletionHandler) + { + _sendbirdChatClient.GetPushTriggerOption(inCompletionHandler); + } + + /// + /// Changes a setting that decides which push notification for the current user to receive in all the group channel. + /// + /// + /// + /// /// @since 4.1.0 + public static void SetPushTriggerOption(SbPushTriggerOption inPushTriggerOption, SbErrorHandler inCompletionHandler) + { + _sendbirdChatClient.SetPushTriggerOption(inPushTriggerOption, inCompletionHandler); + } + /// /// Sets the log level. The log level is defined by SbLogLevel. /// diff --git a/Runtime/Scripts/UnityPlatform/UnityPlatformApplication.cs b/Runtime/Scripts/UnityPlatform/UnityPlatformApplication.cs index 47de8e0..681fa51 100644 --- a/Runtime/Scripts/UnityPlatform/UnityPlatformApplication.cs +++ b/Runtime/Scripts/UnityPlatform/UnityPlatformApplication.cs @@ -9,7 +9,7 @@ namespace Sendbird.Chat { internal class UnityPlatformApplication : IPlatformApplication { - string IPlatformApplication.SdkVersion => "4.0.1"; + string IPlatformApplication.SdkVersion => "4.1.0"; string IPlatformApplication.PlatformName => "Unity"; string IPlatformApplication.PlatformVersion => Application.unityVersion; string IPlatformApplication.OsName => Application.platform.ToString(); diff --git a/package.json b/package.json index e10fcff..a25995f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.sendbird.chat", "displayName": "SendbirdChat", - "version": "4.0.1", + "version": "4.1.0", "documentationUrl": "https://github.com/sendbird/sendbird-chat-sdk-unity", "changelogUrl": "https://github.com/sendbird/sendbird-chat-sdk-unity/blob/master/CHANGELOG.md", "licensesUrl": "https://github.com/sendbird/sendbird-chat-sdk-unity/blob/master/LICENSE.md",