@@ -10,61 +10,253 @@ public class UrbanAirshipBehaviour : MonoBehaviour {
1010 public string addTagOnStart ;
1111
1212 void Awake ( ) {
13- //Airship.Shared.push.SetUserNotificationsEnabled(true);
14- //Airship.Shared.push.UserNotificationsEnabled = true;
13+ Airship . Shared . TakeOff ( new AirshipConfig ( ) {
14+ defaultEnvironment = new ConfigEnvironment ( ) {
15+ appKey = "APP_KEY" ,
16+ appSecret = "APP_SECRET" ,
17+ logLevel = LogLevel . Verbose ,
18+ } ,
19+ site = Site . US ,
20+ inProduction = false ,
21+ urlAllowList = new string [ ] { "*" } ,
22+ } ) ;
1523 }
1624
1725 void Start ( ) {
26+ Debug . Log ( "Airship is flying: " + Airship . Shared . IsFlying ( ) ) ;
27+
28+ Airship . Shared . push . SetUserNotificationsEnabled ( true ) ;
29+
1830 // if (!string.IsNullOrEmpty (addTagOnStart)) {
1931 // UAirship.Shared.AddTag (addTagOnStart);
2032 // }
2133
22- string [ ] allenable = new string [ ] { "FEATURE_ALL" } ;
23- //Airship.Shared.privacyManager.SetEnabledFeatures(allenable);
24-
2534 // UAirship.Shared.OnPushReceived += OnPushReceived;
2635 // UAirship.Shared.OnChannelUpdated += OnChannelUpdated;
2736 // UAirship.Shared.OnDeepLinkReceived += OnDeepLinkReceived;
2837 // UAirship.Shared.OnPushOpened += OnPushOpened;
2938 // UAirship.Shared.OnInboxUpdated += OnInboxUpdated;
3039 // UAirship.Shared.OnShowInbox += OnShowInbox;
3140
41+ // PrivacyManager
42+ Debug . Log ( "Set Enabled features to none" ) ;
43+ Airship . Shared . privacyManager . SetEnabledFeatures ( new string [ ] { "none" } ) ;
44+ Debug . Log ( "Enabled features: " + string . Join ( ", " , Airship . Shared . privacyManager . GetEnabledFeatures ( ) ) ) ;
45+
46+ Debug . Log ( "Enable push and analytics features" ) ;
47+ Airship . Shared . privacyManager . EnableFeatures ( new string [ ] { "push" , "analytics" } ) ;
48+ Debug . Log ( "Enabled features: " + string . Join ( ", " , Airship . Shared . privacyManager . GetEnabledFeatures ( ) ) ) ;
49+
50+ Debug . Log ( "Disable analytics feature" ) ;
51+ Airship . Shared . privacyManager . DisableFeatures ( new string [ ] { "analytics" } ) ;
52+ Debug . Log ( "Enabled features: " + string . Join ( ", " , Airship . Shared . privacyManager . GetEnabledFeatures ( ) ) ) ;
53+
54+ Debug . Log ( "Is push feature enabled: " + Airship . Shared . privacyManager . IsFeaturesEnabled ( new string [ ] { "push" } ) ) ;
55+ Debug . Log ( "Is analytics feature enabled: " + Airship . Shared . privacyManager . IsFeaturesEnabled ( new string [ ] { "analytics" } ) ) ;
56+
57+ Debug . Log ( "Set Enabled features to all" ) ;
58+ Airship . Shared . privacyManager . SetEnabledFeatures ( new string [ ] { "all" } ) ;
59+
60+ // Analytics
3261 Airship . Shared . analytics . TrackScreen ( "Main Camera" ) ;
3362
63+ Airship . Shared . analytics . AssociateIdentifier ( "identifier" , "my_identifier" ) ;
64+
3465 CustomEvent customEvent = new CustomEvent ( ) ;
35- customEvent . EventName = "event_name " ;
66+ customEvent . EventName = "my_event " ;
3667 customEvent . EventValue = 123 ;
3768 Airship . Shared . analytics . AddCustomEvent ( customEvent ) ;
3869
39- Airship . Shared . channel . EditTags ( ) . AddTag ( "ulrich" ) . Apply ( ) ;
70+ Debug . Log ( "Session ID: " + Airship . Shared . analytics . GetSessionId ( ) ) ;
71+
72+ // Channel
73+ Debug . Log ( "Channel ID: " + Airship . Shared . channel . GetChannelId ( ) ) ;
74+
75+ // StartCoroutine(Airship.Shared.channel.WaitForChannelId(
76+ // onComplete: (channelId) => {
77+ // Debug.Log($"Channel ID received: {channelId}");
78+ // },
79+ // onError: (error) => {
80+ // Debug.LogError($"Error getting channel ID: {error.Message}");
81+ // }
82+ // ));
83+
84+ Airship . Shared . channel . EditTags ( ) . AddTag ( "unity_tag" ) . Apply ( ) ;
85+ Airship . Shared . channel . EditTags ( ) . AddTag ( "tag_to_remove_1" ) . Apply ( ) ;
86+ Airship . Shared . channel . EditTags ( ) . AddTags ( new string [ ] { "tag_to_remove_2" , "tag_to_remove_3" } ) . Apply ( ) ;
87+ Debug . Log ( "Tags: " + string . Join ( ", " , Airship . Shared . channel . GetTags ( ) ) ) ;
88+ Airship . Shared . channel . EditTags ( ) . RemoveTag ( "tag_to_remove_1" ) . Apply ( ) ;
89+ Airship . Shared . channel . EditTags ( ) . RemoveTags ( new string [ ] { "tag_to_remove_2" , "tag_to_remove_3" } ) . Apply ( ) ;
90+ Debug . Log ( "Tags: " + string . Join ( ", " , Airship . Shared . channel . GetTags ( ) ) ) ;
91+
92+ Airship . Shared . channel . EditTagGroups ( ) . AddTag ( "unity_tag_group" , "tag_1" ) . Apply ( ) ;
93+ Airship . Shared . channel . EditTagGroups ( ) . AddTags ( "unity_tag_group" , new string [ ] { "tag_2" , "tag_3" } ) . Apply ( ) ;
94+ Airship . Shared . channel . EditTagGroups ( ) . RemoveTag ( "unity_tag_group" , "tag_2" ) . Apply ( ) ;
95+ Airship . Shared . channel . EditTagGroups ( ) . RemoveTags ( "unity_tag_group" , new string [ ] { "tag_3" } ) . Apply ( ) ;
96+
97+ Airship . Shared . channel . EditSubscriptionLists ( ) . Subscribe ( "unity_subscription_list" ) . Apply ( ) ;
98+ Airship . Shared . channel . EditSubscriptionLists ( ) . Subscribe ( "unity_subscription_list_to_remove" ) . Apply ( ) ;
99+ // StartCoroutine(Airship.Shared.channel.GetSubscriptionLists(
100+ // onComplete: (subscriptionLists) => {
101+ // Debug.Log("Channel Subscription lists: " + string.Join(", ", subscriptionLists));
102+ // },
103+ // onError: (error) => {
104+ // Debug.LogError("Error getting subscription lists: " + error.Message);
105+ // }
106+ // ));
107+ Airship . Shared . channel . EditSubscriptionLists ( ) . Unsubscribe ( "unity_subscription_list_to_remove" ) . Apply ( ) ;
40108
41109 Airship . Shared . channel . EditAttributes ( ) . SetAttribute ( "teststring" , "a_string" ) . Apply ( ) ;
42110 Airship . Shared . channel . EditAttributes ( ) . SetAttribute ( "testint" , ( int ) 1 ) . Apply ( ) ;
43111 Airship . Shared . channel . EditAttributes ( ) . SetAttribute ( "testlong" , ( long ) 1000 ) . Apply ( ) ;
44112 Airship . Shared . channel . EditAttributes ( ) . SetAttribute ( "testfloat" , ( float ) 5.99 ) . Apply ( ) ;
45113 Airship . Shared . channel . EditAttributes ( ) . SetAttribute ( "testdouble" , ( double ) 5555.999 ) . Apply ( ) ;
46114 Airship . Shared . channel . EditAttributes ( ) . SetAttribute ( "testdate" , DateTime . UtcNow ) . Apply ( ) ;
47-
115+
48116 Airship . Shared . channel . EditAttributes ( ) . RemoveAttribute ( "teststring" ) . Apply ( ) ;
49117 Airship . Shared . channel . EditAttributes ( ) . RemoveAttribute ( "testint" ) . Apply ( ) ;
50118
51- StartCoroutine ( Airship . Shared . messageCenter . RefreshInbox (
52- onComplete : ( ) => {
53- Debug . Log ( "Refresh inbox complete" ) ;
119+ // Contact
120+ Airship . Shared . contact . Identify ( "my_named_user" ) ;
121+ Debug . Log ( "Named user ID: " + Airship . Shared . contact . GetNamedUserId ( ) ) ;
122+ Airship . Shared . contact . Reset ( ) ;
123+ Debug . Log ( "Named user ID after reset: " + Airship . Shared . contact . GetNamedUserId ( ) ) ;
124+
125+ Airship . Shared . contact . EditTagGroups ( ) . AddTag ( "unity_tag_group" , "tag_1" ) . Apply ( ) ;
126+ Airship . Shared . contact . EditTagGroups ( ) . AddTags ( "unity_tag_group" , new string [ ] { "tag_2" , "tag_3" } ) . Apply ( ) ;
127+ Airship . Shared . contact . EditTagGroups ( ) . RemoveTag ( "unity_tag_group" , "tag_2" ) . Apply ( ) ;
128+ Airship . Shared . contact . EditTagGroups ( ) . RemoveTags ( "unity_tag_group" , new string [ ] { "tag_3" } ) . Apply ( ) ;
129+
130+ Airship . Shared . contact . EditAttributes ( ) . SetAttribute ( "teststring" , "a_string" ) . Apply ( ) ;
131+ Airship . Shared . contact . EditAttributes ( ) . SetAttribute ( "testint" , ( int ) 1 ) . Apply ( ) ;
132+ Airship . Shared . contact . EditAttributes ( ) . SetAttribute ( "testlong" , ( long ) 1000 ) . Apply ( ) ;
133+ Airship . Shared . contact . EditAttributes ( ) . SetAttribute ( "testfloat" , ( float ) 5.99 ) . Apply ( ) ;
134+ Airship . Shared . contact . EditAttributes ( ) . SetAttribute ( "testdouble" , ( double ) 5555.999 ) . Apply ( ) ;
135+ Airship . Shared . contact . EditAttributes ( ) . SetAttribute ( "testdate" , DateTime . UtcNow ) . Apply ( ) ;
136+ Airship . Shared . contact . EditAttributes ( ) . RemoveAttribute ( "teststring" ) . Apply ( ) ;
137+ Airship . Shared . contact . EditAttributes ( ) . RemoveAttribute ( "testint" ) . Apply ( ) ;
138+
139+ Airship . Shared . contact . EditSubscriptionLists ( ) . Subscribe ( "unity_subscription_list" , SubscriptionScope . APP ) . Apply ( ) ;
140+ Airship . Shared . contact . EditSubscriptionLists ( ) . Subscribe ( "unity_subscription_list_to_remove" , SubscriptionScope . APP ) . Apply ( ) ;
141+ Airship . Shared . contact . EditSubscriptionLists ( ) . Unsubscribe ( "unity_subscription_list_to_remove" , SubscriptionScope . APP ) . Apply ( ) ;
142+ Debug . Log ( "Contact Subscription lists: " + string . Join ( ", " , Airship . Shared . contact . GetSubscriptionLists ( ) ) ) ;
143+ // StartCoroutine(Airship.Shared.contact.GetSubscriptionLists(
144+ // onComplete: (subscriptionLists) => {
145+ // Debug.Log("Contact Subscription lists: " + string.Join(", ", subscriptionLists));
146+ // },
147+ // onError: (error) => {
148+ // Debug.LogError("Error getting subscription lists: " + error.Message);
149+ // }
150+ // ));
151+
152+ // InApp
153+ Airship . Shared . inApp . SetPaused ( true ) ;
154+ Debug . Log ( "InApp paused after true: " + Airship . Shared . inApp . IsPaused ( ) ) ;
155+ Airship . Shared . inApp . SetPaused ( false ) ;
156+ Debug . Log ( "InApp paused after false: " + Airship . Shared . inApp . IsPaused ( ) ) ;
157+
158+ Airship . Shared . inApp . SetDisplayInterval ( TimeSpan . FromSeconds ( 10 ) ) ;
159+ Debug . Log ( "InApp display interval: " + Airship . Shared . inApp . GetDisplayInterval ( ) ) ;
160+
161+ // Locale
162+ Airship . Shared . locale . SetLocaleOverride ( "en_US" ) ;
163+ Airship . Shared . locale . ClearLocaleOverride ( ) ;
164+ // Debug.Log("Locale: " + Airship.Shared.locale.GetLocale());
165+
166+ // Message Center
167+ // StartCoroutine(Airship.Shared.messageCenter.RefreshInbox(
168+ // onComplete: () => {
169+ // Debug.Log("Refresh inbox complete");
170+ // },
171+ // onError: (error) => {
172+ // Debug.LogError("Error refreshing inbox: " + error.Message);
173+ // }
174+ // ));
175+
176+ Airship . Shared . messageCenter . SetAutoLaunchDefaultMessageCenter ( true ) ;
177+
178+ // StartCoroutine(Airship.Shared.messageCenter.GetUnReadCount(
179+ // onComplete: (unreadCount) => {
180+ // Debug.Log("Unread count: " + unreadCount);
181+ // },
182+ // onError: (error) => {
183+ // Debug.LogError("Error getting unread count: " + error.Message);
184+ // }
185+ // ));
186+
187+ // StartCoroutine(Airship.Shared.messageCenter.GetMessages(
188+ // onComplete: (messages) => {
189+ // Debug.Log("Messages: " + string.Join(", ", messages));
190+ // },
191+ // onError: (error) => {
192+ // Debug.LogError("Error getting messages: " + error.Message);
193+ // }
194+ // ));
195+
196+ Airship . Shared . messageCenter . Display ( null ) ;
197+ // Airship.Shared.messageCenter.ShowMessageCenter(null);
198+ Airship . Shared . messageCenter . Dismiss ( ) ;
199+
200+ // Preference Center
201+ Airship . Shared . preferenceCenter . SetAutoLaunchDefaultPreferenceCenter ( "neat" , true ) ;
202+ // Airship.Shared.preferenceCenter.Display("neat");
203+ // StartCoroutine(Airship.Shared.preferenceCenter.GetConfig("neat",
204+ // onComplete: (config) => {
205+ // Debug.Log("Config: " + JsonUtility.ToJson(config));
206+ // },
207+ // onError: (error) => {
208+ // Debug.LogError("Error getting config: " + error.Message);
209+ // }
210+ // ));
211+
212+ // Push
213+
214+ Airship . Shared . push . SetUserNotificationsEnabled ( false ) ;
215+ Debug . Log ( "User notifications enabled after set to false: " + Airship . Shared . push . IsUserNotificationEnabled ( ) ) ;
216+ // Airship.Shared.push.SetUserNotificationsEnabled(true);
217+ // Debug.Log("User notifications enabled after set to true: " + Airship.Shared.push.IsUserNotificationEnabled());
218+
219+ StartCoroutine ( Airship . Shared . push . EnableUserNotifications (
220+ new EnabledUserPushNotificationsArgs ( ) {
221+ fallback = PromptPermissionFallback . SystemSettings
222+ } ,
223+ onComplete : ( result ) => {
224+ Debug . Log ( "User notifications enabled: " + result ) ;
54225 } ,
55226 onError : ( error ) => {
56- Debug . LogError ( "Error refreshing inbox : " + error . Message ) ;
227+ Debug . LogError ( "Error enabling user notifications : " + error . Message ) ;
57228 }
58229 ) ) ;
59230
60- StartCoroutine ( Airship . Shared . channel . WaitForChannelId (
61- onComplete : ( channelId ) => {
62- Debug . Log ( $ "Channel ID received: { channelId } " ) ;
231+ StartCoroutine ( Airship . Shared . push . GetNotificationStatus (
232+ onComplete : ( status ) => {
233+ Debug . Log ( "Notification status: " + status ) ;
63234 } ,
64235 onError : ( error ) => {
65- Debug . LogError ( $ "Error getting channel ID: { error . Message } " ) ;
236+ Debug . LogError ( "Error getting notification status: " + error . Message ) ;
66237 }
67238 ) ) ;
239+
240+ Debug . Log ( "Push token: " + Airship . Shared . push . GetPushToken ( ) ) ;
241+
242+ Debug . Log ( "Active notifications: " + string . Join ( ", " , Airship . Shared . push . GetActiveNotifications ( ) ) ) ;
243+
244+ // Airship.Shared.push.ClearNotifications();
245+ // Debug.Log("Notifications cleared");
246+
247+ Debug . Log ( "Is notification channel enabled: " + Airship . Shared . push . android . IsNotificationChannelEnabled ( "test_channel" ) ) ;
248+
249+ Airship . Shared . push . android . SetNotificationConfig ( new AndroidNotificationConfig ( ) {
250+ icon = "ic_notification" ,
251+ largeIcon = "ic_notification_large" ,
252+ defaultChannelId = "test_channel" ,
253+ accentColor = "#FF0000" ,
254+ } ) ;
255+
256+ Airship . Shared . push . android . SetForegroundNotificationsEnabled ( true ) ;
257+ // Debug.Log("Foreground notifications enabled: " + Airship.Shared.push.android.IsForegroundNotificationsEnabled());
258+ // Airship.Shared.push.android.SetForegroundNotificationsEnabled(false);
259+ // Debug.Log("Foreground notifications enabled after false: " + Airship.Shared.push.android.IsForegroundNotificationsEnabled());
68260 }
69261
70262 // void OnDestroy () {
0 commit comments