Skip to content

Commit 5f43c55

Browse files
authored
Merge pull request #127 from urbanairship/MOBILE-2533
[MOBILE-2533] Update Unity to latest SDKs
2 parents 93bd8a0 + 1df0f31 commit 5f43c55

17 files changed

+532
-321
lines changed

Assets/Plugins/iOS/UAUnityMessageViewController.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#import "UAMessageCenterResources.h"
1111
#import "UAMessageCenterLocalization.h"
1212
#else
13-
@import Airship;
13+
@import AirshipKit;
1414
#endif
1515

1616
NS_ASSUME_NONNULL_BEGIN

Assets/Plugins/iOS/UAUnityPlugin.h

+18-14
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#import "UADefaultMessageCenterUI.h"
1313
#import "UAAssociatedIdentifiers.h"
1414
#else
15-
@import Airship;
15+
@import AirshipKit;
1616
#endif
1717

1818
extern void UnitySendMessage(const char *, const char *, const char *);
@@ -41,15 +41,6 @@ void UAUnityPlugin_removeTag(const char* tag);
4141

4242
const char* UAUnityPlugin_getChannelId();
4343

44-
#pragma mark -
45-
#pragma mark UA Location Functions
46-
47-
bool UAUnityPlugin_isLocationEnabled();
48-
void UAUnityPlugin_setLocationEnabled(bool enabled);
49-
50-
bool UAUnityPlugin_isBackgroundLocationAllowed();
51-
void UAUnityPlugin_setBackgroundLocationAllowed(bool allowed);
52-
5344
#pragma mark -
5445
#pragma mark Custom Events
5546
void UAUnityPlugin_addCustomEvent(const char *customEvent);
@@ -97,10 +88,23 @@ void UAUnityPlugin_editNamedUserAttributes(const char *payload);
9788

9889
#pragma mark -
9990
#pragma mark Data Collection
100-
bool UAUnityPlugin_isDataCollectionEnabled();
101-
void UAUnityPlugin_setDataCollectionEnabled(bool enabled);
102-
bool UAUnityPlugin_isPushTokenRegistrationEnabled();
103-
void UAUnityPlugin_setPushTokenRegistrationEnabled(bool enabled);
91+
void UAUnityPlugin_setEnabledFeatures(const char *features);
92+
void UAUnityPlugin_enableFeatures(const char *features);
93+
void UAUnityPlugin_disableFeatures(const char *features);
94+
bool UAUnityPlugin_isFeatureEnabled(const char *feature);
95+
bool UAUnityPlugin_isAnyFeatureEnabled();
96+
const char* UAUnityPlugin_getEnabledFeatures();
97+
98+
#pragma mark -
99+
#pragma mark Preference Center
100+
101+
void UAUnityPlugin_openPreferenceCenter(NSString *preferenceCenterId);
102+
103+
#pragma mark -
104+
#pragma mark Helpers
105+
bool isValidFeature(NSArray *features);
106+
UAFeatures stringToFeature(NSArray *features);
107+
NSArray * featureToString(UAFeatures features);
104108

105109
@interface UAUnityPlugin : NSObject <UAPushNotificationDelegate, UADeepLinkDelegate, UAMessageCenterDisplayDelegate>
106110

Assets/Plugins/iOS/UAUnityPlugin.m

+160-61
Large diffs are not rendered by default.

Assets/Scripts/UrbanAirshipBehaviour.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Copyright Airship and Contributors */
22

3-
using System;
3+
using System;
44
using System.Collections;
55
using System.Collections.Generic;
66
using UnityEngine;
@@ -10,8 +10,6 @@ public class UrbanAirshipBehaviour : MonoBehaviour {
1010
public string addTagOnStart;
1111

1212
void Awake () {
13-
UAirship.Shared.DataCollectionEnabled = true;
14-
UAirship.Shared.PushTokenRegistrationEnabled = true;
1513
UAirship.Shared.UserNotificationsEnabled = true;
1614
}
1715

@@ -20,6 +18,9 @@ void Start () {
2018
UAirship.Shared.AddTag (addTagOnStart);
2119
}
2220

21+
string[] allenable = new string[] { "FEATURE_ALL" };
22+
UAirship.Shared.SetEnabledFeatures(allenable);
23+
2324
UAirship.Shared.OnPushReceived += OnPushReceived;
2425
UAirship.Shared.OnChannelUpdated += OnChannelUpdated;
2526
UAirship.Shared.OnDeepLinkReceived += OnDeepLinkReceived;

Assets/UrbanAirship/Editor/UAConfig.cs

+16-4
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public enum CloudSite {
7878
public String UrlAllowListScopeJavaScriptInterface { get; set; }
7979

8080
[SerializeField]
81-
public bool DataCollectionOptInEnabled { get; set; }
81+
public String EnabledFeatures { get; set; }
8282

8383
[SerializeField]
8484
public String AndroidNotificationIcon { get; set; }
@@ -126,7 +126,7 @@ public UAConfig (UAConfig config) {
126126
this.UrlAllowListScopeOpenURL = config.UrlAllowListScopeOpenURL;
127127
this.UrlAllowListScopeJavaScriptInterface = config.UrlAllowListScopeJavaScriptInterface;
128128

129-
this.DataCollectionOptInEnabled = config.DataCollectionOptInEnabled;
129+
this.EnabledFeatures = config.EnabledFeatures;
130130

131131
this.NotificationPresentationOptionAlert = config.NotificationPresentationOptionAlert;
132132
this.NotificationPresentationOptionBadge = config.NotificationPresentationOptionBadge;
@@ -271,7 +271,6 @@ private void GenerateIOSAirshipConfig () {
271271

272272
rootDict.SetString ("site", Site.ToString());
273273
rootDict.SetBoolean ("inProduction", InProduction);
274-
rootDict.SetBoolean ("dataCollectionOptInEnabled", DataCollectionOptInEnabled);
275274

276275
if (!String.IsNullOrEmpty(UrlAllowList))
277276
{
@@ -300,6 +299,15 @@ private void GenerateIOSAirshipConfig () {
300299
}
301300
}
302301

302+
if (!String.IsNullOrEmpty(EnabledFeatures))
303+
{
304+
PlistElementArray enabledFeaturesConfig = rootDict.CreateArray("enabledFeatures");
305+
foreach (string feature in EnabledFeatures.Split(','))
306+
{
307+
enabledFeaturesConfig.AddString(feature);
308+
}
309+
}
310+
303311
PlistElementDict customConfig = rootDict.CreateDict ("customConfig");
304312
customConfig.SetBoolean ("notificationPresentationOptionAlert", NotificationPresentationOptionAlert);
305313
customConfig.SetBoolean ("notificationPresentationOptionBadge", NotificationPresentationOptionBadge);
@@ -355,7 +363,6 @@ private void GenerateAndroidAirshipConfig () {
355363

356364
xmlWriter.WriteAttributeString ("site", Site.ToString());
357365
xmlWriter.WriteAttributeString ("inProduction", (InProduction ? "true" : "false"));
358-
xmlWriter.WriteAttributeString ("dataCollectionOptInEnabled", (DataCollectionOptInEnabled ? "true" : "false"));
359366

360367
if (!String.IsNullOrEmpty(UrlAllowList))
361368
{
@@ -372,6 +379,11 @@ private void GenerateAndroidAirshipConfig () {
372379
xmlWriter.WriteAttributeString ("urlAllowListScopeJavaScriptInterface", UrlAllowListScopeJavaScriptInterface.ToString());
373380
}
374381

382+
if (!String.IsNullOrEmpty(EnabledFeatures))
383+
{
384+
xmlWriter.WriteAttributeString ("enabledFeatures", EnabledFeatures.ToString());
385+
}
386+
375387
if (!String.IsNullOrEmpty (AndroidNotificationIcon)) {
376388
xmlWriter.WriteAttributeString ("notificationIcon", AndroidNotificationIcon);
377389
}

Assets/UrbanAirship/Editor/UAConfigEditor.cs

+4-6
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ void OnGUI () {
3535
CreateSection ("Common", () => {
3636
config.InProduction = EditorGUILayout.Toggle ("inProduction", config.InProduction);
3737
config.Site = (UAConfig.CloudSite) EditorGUILayout.EnumPopup ("Cloud Site", config.Site);
38-
config.DataCollectionOptInEnabled = EditorGUILayout.Toggle ("Data Collection Opt-In", config.DataCollectionOptInEnabled);
39-
GUILayout.Label ("When data collection opt-in is enabled, data collection will be disabled by default until the app enables it by calling " +
40-
"`UAirship.Shared.DataCollectionEnabled = true`. When disabled, the device will stop collection and sending data for named user, events, tags " +
41-
"attributes, associated identifiers, and location from the device. Push notifications will continue to work only if " +
42-
"`UAirship.Shared.PushTokenRegistrationEnabled = true` is called, otherwise it will default to the current state of DataCollectionEnabled.",
43-
EditorStyles.wordWrappedMiniLabel);
4438
});
4539

4640
CreateSection ("URL Allow List", () => {
@@ -49,6 +43,10 @@ void OnGUI () {
4943
config.UrlAllowListScopeJavaScriptInterface = EditorGUILayout.TextField ("Scope JS Interface", config.UrlAllowListScopeJavaScriptInterface);
5044
});
5145

46+
CreateSection ("Data Collection", () => {
47+
config.EnabledFeatures = EditorGUILayout.TextField ("Enabled Features", config.EnabledFeatures);
48+
});
49+
5250
CreateSection ("Android Settings", () => {
5351
config.GenerateGoogleJsonConfig = EditorGUILayout.Toggle ("Process google-service", config.GenerateGoogleJsonConfig);
5452
config.AndroidNotificationAccentColor = EditorGUILayout.TextField ("Notification Accent Color", config.AndroidNotificationAccentColor);

Assets/UrbanAirship/Editor/UADependencies.xml

+9-6
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
</repositories>
1919
</androidPackage>
2020

21-
<!-- Urban Airship Location -->
22-
<androidPackage spec="com.urbanairship.android:urbanairship-location:__ANDROID_AIRSHIP_VERSION__">
21+
<!-- Urban Airship FCM -->
22+
<androidPackage spec="com.urbanairship.android:urbanairship-fcm:__ANDROID_AIRSHIP_VERSION__">
2323
<repositories>
2424
<repository>https://urbanairship.bintray.com/android</repository>
2525
</repositories>
2626
</androidPackage>
2727

28-
<!-- Urban Airship FCM -->
29-
<androidPackage spec="com.urbanairship.android:urbanairship-fcm:__ANDROID_AIRSHIP_VERSION__">
28+
<!-- Urban Airship Preference Center -->
29+
<androidPackage spec="com.urbanairship.android:urbanairship-preference-center:__ANDROID_AIRSHIP_VERSION__">
3030
<repositories>
3131
<repository>https://urbanairship.bintray.com/android</repository>
3232
</repositories>
@@ -39,8 +39,11 @@
3939
<iosPods>
4040

4141
<!-- iosPod -->
42-
<iosPod name="Airship" version="__IOS_AIRSHIP_VERSION__" minTargetSdk="11.0" />
43-
<iosPod name="Airship/Location" version="__IOS_AIRSHIP_VERSION__" minTargetSdk="11.0" />
42+
<iosPod name="Airship/Core" version="__IOS_AIRSHIP_VERSION__" minTargetSdk="11.0" />
43+
<iosPod name="Airship/MessageCenter" version="__IOS_AIRSHIP_VERSION__" minTargetSdk="11.0" />
44+
<iosPod name="Airship/Automation" version="__IOS_AIRSHIP_VERSION__" minTargetSdk="11.0" />
45+
<iosPod name="Airship/ExtendedActions" version="__IOS_AIRSHIP_VERSION__" minTargetSdk="11.0" />
46+
<iosPod name="Airship/PreferenceCenter" version="__IOS_AIRSHIP_VERSION__" minTargetSdk="11.0" />
4447

4548
</iosPods>
4649

Assets/UrbanAirship/Platforms/Android/UAirshipPluginAndroid.cs

+41-36
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System;
66
using System.Collections;
77
using System.Collections.Generic;
8+
using System.Linq;
89
using UnityEngine;
910

1011
namespace UrbanAirship {
@@ -44,24 +45,6 @@ public string ChannelId {
4445
}
4546
}
4647

47-
public bool LocationEnabled {
48-
get {
49-
return Call<bool> ("isLocationEnabled");
50-
}
51-
set {
52-
Call ("setLocationEnabled", value);
53-
}
54-
}
55-
56-
public bool BackgroundLocationAllowed {
57-
get {
58-
return Call<bool> ("isBackgroundLocationAllowed");
59-
}
60-
set {
61-
Call ("setBackgroundLocationAllowed", value);
62-
}
63-
}
64-
6548
public string NamedUserId {
6649
get {
6750
return Call<string> ("getNamedUserId");
@@ -180,6 +163,46 @@ public void EditNamedUserAttributes (string payload) {
180163
Call ("editNamedUserAttributes", payload);
181164
}
182165

166+
public void OpenPreferenceCenter (string preferenceCenterId) {
167+
Call ("openPreferenceCenter", preferenceCenterId);
168+
}
169+
170+
public void SetEnabledFeatures (string[] enabledFeatures) {
171+
Call ("setEnabledFeatures", MakeJavaArray(enabledFeatures));
172+
}
173+
174+
public void EnableFeatures (string[] enabledFeatures) {
175+
Call ("enableFeatures", MakeJavaArray(enabledFeatures));
176+
}
177+
178+
public void DisableFeatures (string[] disabledFeatures) {
179+
Call ("disableFeatures", MakeJavaArray(disabledFeatures));
180+
}
181+
182+
public bool IsFeatureEnabled (string[] features) {
183+
return Call<bool> ("isFeatureEnabled", MakeJavaArray(features));
184+
}
185+
186+
public bool IsAnyFeatureEnabled (string[] features) {
187+
return Call<bool> ("isAnyFeatureEnabled", MakeJavaArray(features));
188+
}
189+
190+
public string[] GetEnabledFeatures () {
191+
return Call<string[]> ("getEnabledFeatures");
192+
}
193+
194+
/// Internal method to make a Java Array with an array of String values, to be used with the
195+
/// "setEnabledFeatures" method.
196+
private AndroidJavaObject MakeJavaArray(string [] values) {
197+
AndroidJavaClass arrayClass = new AndroidJavaClass("java.lang.reflect.Array");
198+
AndroidJavaObject arrayObject = arrayClass.CallStatic<AndroidJavaObject>("newInstance", new AndroidJavaClass("java.lang.String"), values.Count());
199+
for (int i=0; i<values.Count(); ++i) {
200+
arrayClass.CallStatic("set", arrayObject, i, new AndroidJavaObject("java.lang.String", values[i]));
201+
}
202+
203+
return arrayObject;
204+
}
205+
183206
private void Call (string method, params object[] args) {
184207
if (androidPlugin != null) {
185208
androidPlugin.Call (method, args);
@@ -192,24 +215,6 @@ private T Call<T> (string method, params object[] args) {
192215
}
193216
return default (T);
194217
}
195-
196-
public bool DataCollectionEnabled {
197-
get {
198-
return Call<bool> ("isDataCollectionEnabled");
199-
}
200-
set {
201-
Call ("setDataCollectionEnabled", value);
202-
}
203-
}
204-
205-
public bool PushTokenRegistrationEnabled {
206-
get {
207-
return Call<bool> ("isPushTokenRegistrationEnabled");
208-
}
209-
set {
210-
Call ("setPushTokenRegistrationEnabled", value);
211-
}
212-
}
213218
}
214219
}
215220

Assets/UrbanAirship/Platforms/IUAirshipPlugin.cs

+14-20
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@ string ChannelId {
2121
get;
2222
}
2323

24-
bool LocationEnabled {
25-
get;
26-
set;
27-
}
28-
29-
bool BackgroundLocationAllowed {
30-
get;
31-
set;
32-
}
33-
3424
string NamedUserId {
3525
get;
3626
set;
@@ -40,16 +30,6 @@ GameObject Listener {
4030
set;
4131
}
4232

43-
bool DataCollectionEnabled {
44-
get;
45-
set;
46-
}
47-
48-
bool PushTokenRegistrationEnabled {
49-
get;
50-
set;
51-
}
52-
5333
string GetDeepLink (bool clear);
5434

5535
string GetIncomingPush (bool clear);
@@ -94,6 +74,20 @@ int MessageCenterCount {
9474

9575
void EditNamedUserAttributes (string payload);
9676

77+
void OpenPreferenceCenter (string preferenceCenterId);
78+
79+
void SetEnabledFeatures (string[] enabledFeatures);
80+
81+
void EnableFeatures (string[] enabledFeatures);
82+
83+
void DisableFeatures (string[] disabledFeatures);
84+
85+
bool IsFeatureEnabled (string[] features);
86+
87+
bool IsAnyFeatureEnabled (string[] features);
88+
89+
string[] GetEnabledFeatures ();
90+
9791
TimeSpan InAppAutomationDisplayInterval {
9892
get;
9993
set;

Assets/UrbanAirship/Platforms/StubbedPlugin.cs

+7-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ class StubbedPlugin : IUAirshipPlugin {
88
public bool UserNotificationsEnabled { get; set; }
99
public string Tags { get { return null; } }
1010
public string ChannelId { get { return null; } }
11-
public bool LocationEnabled { get; set; }
12-
public bool BackgroundLocationAllowed { get; set; }
1311
public string NamedUserId { get; set; }
1412
public TimeSpan InAppAutomationDisplayInterval { get; set; }
1513
public bool InAppAutomationPaused { get; set; }
@@ -34,7 +32,12 @@ public void EditNamedUserTagGroups (string payload) { }
3432
public void EditChannelTagGroups (string payload) { }
3533
public void EditChannelAttributes (string payload) { }
3634
public void EditNamedUserAttributes (string payload) { }
37-
public bool DataCollectionEnabled { get; set; }
38-
public bool PushTokenRegistrationEnabled { get; set; }
35+
public void OpenPreferenceCenter (string preferenceCenterId) { }
36+
public void SetEnabledFeatures (string[] enabledFeatures) { }
37+
public void EnableFeatures (string[] enabledFeatures) { }
38+
public void DisableFeatures (string[] disabledFeatures) { }
39+
public bool IsFeatureEnabled (string[] features) { return false; }
40+
public bool IsAnyFeatureEnabled (string[] features) { return false; }
41+
public string[] GetEnabledFeatures () { return null; }
3942
}
4043
}

0 commit comments

Comments
 (0)