com.onesignal.unity.ios 5.1.6 → 5.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Editor/OneSignaliOSDependencies.xml +1 -1
- package/Runtime/OneSignaliOS.cs +3 -1
- package/Runtime/Plugins/iOS/OneSignalUnityBridgeLiveActivities.mm +66 -0
- package/Runtime/Plugins/iOS/UIApplication+OneSignalUnity.mm +1 -1
- package/Runtime/iOSLiveActivitiesManager.cs +36 -0
- package/package.json +2 -2
- package/Runtime/OneSignaliOSInit.cs +0 -42
- package/Runtime/OneSignaliOSInit.cs.meta +0 -11
package/Runtime/OneSignaliOS.cs
CHANGED
|
@@ -69,8 +69,10 @@ namespace OneSignalSDK.iOS {
|
|
|
69
69
|
/// Used to provide a reference for and sets up the global callbacks
|
|
70
70
|
/// </summary>
|
|
71
71
|
public OneSignaliOS() {
|
|
72
|
-
if (_instance != null)
|
|
72
|
+
if (_instance != null) {
|
|
73
73
|
SDKDebug.Error("Additional instance of OneSignaliOS created.");
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
74
76
|
|
|
75
77
|
_instance = this;
|
|
76
78
|
_debug = new iOSDebugManager();
|
|
@@ -29,7 +29,9 @@
|
|
|
29
29
|
#import <OneSignalOSCore/OneSignalOSCore-Swift.h>
|
|
30
30
|
#import <OneSignalNotifications/OneSignalNotifications.h>
|
|
31
31
|
#import <OneSignalUser/OneSignalUser-Swift.h>
|
|
32
|
+
#import "OneSignalLiveActivities/OneSignalLiveActivities-Swift.h"
|
|
32
33
|
#import <OneSignalFramework/OneSignalFramework.h>
|
|
34
|
+
#import "OneSignalBridgeUtil.h"
|
|
33
35
|
|
|
34
36
|
typedef void (*BooleanResponseDelegate)(int hashCode, bool response);
|
|
35
37
|
|
|
@@ -57,4 +59,68 @@ extern "C" {
|
|
|
57
59
|
withSuccess:^(NSDictionary *result) { CALLBACK(YES); }
|
|
58
60
|
withFailure:^(NSError *error) { CALLBACK(NO); }];
|
|
59
61
|
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
void _oneSignalSetupDefaultLiveActivity(const char* optionsJson) {
|
|
65
|
+
#if !TARGET_OS_MACCATALYST
|
|
66
|
+
LiveActivitySetupOptions *laOptions = nil;
|
|
67
|
+
|
|
68
|
+
if (optionsJson) {
|
|
69
|
+
NSDictionary *optionsDict = oneSignalDictionaryFromJsonString(optionsJson);
|
|
70
|
+
|
|
71
|
+
laOptions = [LiveActivitySetupOptions alloc];
|
|
72
|
+
[laOptions setEnablePushToStart:[optionsDict[@"enablePushToStart"] boolValue]];
|
|
73
|
+
[laOptions setEnablePushToUpdate:[optionsDict[@"enablePushToUpdate"] boolValue]];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (@available(iOS 16.1, *)) {
|
|
77
|
+
[OneSignalLiveActivitiesManagerImpl setupDefaultWithOptions:laOptions];
|
|
78
|
+
} else {
|
|
79
|
+
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"cannot setupDefault on iOS < 16.1"]];
|
|
80
|
+
}
|
|
81
|
+
#endif
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
void _oneSignalStartDefaultLiveActivity(const char* activityId, const char* attributesJson, const char* contentJson) {
|
|
85
|
+
#if !TARGET_OS_MACCATALYST
|
|
86
|
+
if (@available(iOS 16.1, *)) {
|
|
87
|
+
NSDictionary *attributes = oneSignalDictionaryFromJsonString(attributesJson);
|
|
88
|
+
NSDictionary *content = oneSignalDictionaryFromJsonString(contentJson);
|
|
89
|
+
|
|
90
|
+
[OneSignalLiveActivitiesManagerImpl startDefault:TO_NSSTRING(activityId) attributes:attributes content:content];
|
|
91
|
+
} else {
|
|
92
|
+
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"cannot startDefault on iOS < 16.1"]];
|
|
93
|
+
}
|
|
94
|
+
#endif
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
void _oneSignalSetPushToStartToken(const char* activityType, const char* token) {
|
|
98
|
+
#if !TARGET_OS_MACCATALYST
|
|
99
|
+
NSError* err=nil;
|
|
100
|
+
|
|
101
|
+
if (@available(iOS 17.2, *)) {
|
|
102
|
+
[OneSignalLiveActivitiesManagerImpl setPushToStartToken:TO_NSSTRING(activityType) withToken:TO_NSSTRING(token) error:&err];
|
|
103
|
+
if (err) {
|
|
104
|
+
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"activityType must be the name of your ActivityAttributes struct"]];
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"cannot setPushToStartToken on iOS < 17.2"]];
|
|
108
|
+
}
|
|
109
|
+
#endif
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
void _oneSignalRemovePushToStartToken(const char* activityType) {
|
|
113
|
+
#if !TARGET_OS_MACCATALYST
|
|
114
|
+
NSError* err=nil;
|
|
115
|
+
if (@available(iOS 17.2, *)) {
|
|
116
|
+
[OneSignalLiveActivitiesManagerImpl removePushToStartToken:TO_NSSTRING(activityType) error:&err];
|
|
117
|
+
|
|
118
|
+
if (err) {
|
|
119
|
+
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"activityType must be the name of your ActivityAttributes struct"]];
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"cannot removePushToStartToken on iOS < 17.2"]];
|
|
123
|
+
}
|
|
124
|
+
#endif
|
|
125
|
+
}
|
|
60
126
|
}
|
|
@@ -97,7 +97,7 @@ static bool swizzled = false;
|
|
|
97
97
|
|
|
98
98
|
- (BOOL)oneSignalApplication:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
|
99
99
|
[OneSignalWrapper setSdkType:@"unity"];
|
|
100
|
-
[OneSignalWrapper setSdkVersion:@"
|
|
100
|
+
[OneSignalWrapper setSdkVersion:@"050107"];
|
|
101
101
|
[OneSignal initialize:nil withLaunchOptions:launchOptions];
|
|
102
102
|
|
|
103
103
|
if ([self respondsToSelector:@selector(oneSignalApplication:didFinishLaunchingWithOptions:)])
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
* THE SOFTWARE.
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
+
using System.Collections.Generic;
|
|
28
29
|
using System.Threading.Tasks;
|
|
29
30
|
using System.Runtime.InteropServices;
|
|
30
31
|
using OneSignalSDK.LiveActivities;
|
|
@@ -32,9 +33,14 @@ using OneSignalSDK.iOS.Utilities;
|
|
|
32
33
|
|
|
33
34
|
namespace OneSignalSDK.iOS.LiveActivities {
|
|
34
35
|
internal sealed class iOSLiveActivitiesManager : ILiveActivitiesManager {
|
|
36
|
+
[DllImport("__Internal")] private static extern void _oneSignalSetupDefaultLiveActivity(string optionsJson);
|
|
37
|
+
[DllImport("__Internal")] private static extern void _oneSignalStartDefaultLiveActivity(string activityId, string attributesJson, string contentJson);
|
|
35
38
|
[DllImport("__Internal")] private static extern void _oneSignalEnterLiveActivity(string activityId, string token, int hashCode, BooleanResponseDelegate callback);
|
|
36
39
|
[DllImport("__Internal")] private static extern void _oneSignalExitLiveActivity(string activityId, int hashCode, BooleanResponseDelegate callback);
|
|
37
40
|
|
|
41
|
+
[DllImport("__Internal")] private static extern void _oneSignalSetPushToStartToken(string activityType, string token);
|
|
42
|
+
[DllImport("__Internal")] private static extern void _oneSignalRemovePushToStartToken(string activityType);
|
|
43
|
+
|
|
38
44
|
private delegate void BooleanResponseDelegate(int hashCode, bool response);
|
|
39
45
|
|
|
40
46
|
public async Task<bool> EnterAsync(string activityId, string token) {
|
|
@@ -49,6 +55,36 @@ namespace OneSignalSDK.iOS.LiveActivities {
|
|
|
49
55
|
return await proxy;
|
|
50
56
|
}
|
|
51
57
|
|
|
58
|
+
public void RemovePushToStartToken(string activityType)
|
|
59
|
+
{
|
|
60
|
+
_oneSignalRemovePushToStartToken(activityType);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public void SetPushToStartToken(string activityType, string token)
|
|
64
|
+
{
|
|
65
|
+
_oneSignalSetPushToStartToken(activityType, token);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public void SetupDefault(LiveActivitySetupOptions options = null)
|
|
69
|
+
{
|
|
70
|
+
string optionsJson = null;
|
|
71
|
+
if (options != null)
|
|
72
|
+
{
|
|
73
|
+
optionsJson = Json.Serialize(new Dictionary<string, object>
|
|
74
|
+
{
|
|
75
|
+
{ "enablePushToStart", options.EnablePushToStart },
|
|
76
|
+
{ "enablePushToUpdate", options.EnablePushToUpdate }
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
_oneSignalSetupDefaultLiveActivity(optionsJson);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
public void StartDefault(string activityId, IDictionary<string, object> attributes, IDictionary<string, object> content)
|
|
84
|
+
{
|
|
85
|
+
_oneSignalStartDefaultLiveActivity(activityId, Json.Serialize(attributes), Json.Serialize(content));
|
|
86
|
+
}
|
|
87
|
+
|
|
52
88
|
[AOT.MonoPInvokeCallback(typeof(BooleanResponseDelegate))]
|
|
53
89
|
private static void BooleanCallbackProxy(int hashCode, bool response)
|
|
54
90
|
=> WaitingProxy.ResolveCallbackProxy(hashCode, response);
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "com.onesignal.unity.ios",
|
|
3
3
|
"displayName": "OneSignal Unity SDK - iOS",
|
|
4
|
-
"version": "5.1.
|
|
4
|
+
"version": "5.1.7",
|
|
5
5
|
"unity": "2018.4",
|
|
6
6
|
"description": "OneSignal is the market leader in customer engagement, powering mobile push, web push, email, and in-app messages.",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"com.onesignal.unity.core": "5.1.
|
|
8
|
+
"com.onesignal.unity.core": "5.1.7"
|
|
9
9
|
},
|
|
10
10
|
"keywords": [
|
|
11
11
|
"push-notifications",
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Modified MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright 2023 OneSignal
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* 1. The above copyright notice and this permission notice shall be included in
|
|
14
|
-
* all copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* 2. All copies of substantial portions of the Software may only be used in connection
|
|
17
|
-
* with services provided by OneSignal.
|
|
18
|
-
*
|
|
19
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
25
|
-
* THE SOFTWARE.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
#if UNITY_IOS && !UNITY_EDITOR
|
|
29
|
-
using UnityEngine;
|
|
30
|
-
|
|
31
|
-
namespace OneSignalSDK.iOS {
|
|
32
|
-
/// <summary>
|
|
33
|
-
///
|
|
34
|
-
/// </summary>
|
|
35
|
-
internal static class OneSignaliOSInit {
|
|
36
|
-
[RuntimeInitializeOnLoadMethod] public static void Init() {
|
|
37
|
-
if (!OneSignalPlatform.DidInitialize)
|
|
38
|
-
OneSignal.Default = new OneSignaliOS();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
#endif
|