Skip to content

Commit b102c32

Browse files
committed
wip
1 parent 238caea commit b102c32

File tree

5 files changed

+266
-204
lines changed

5 files changed

+266
-204
lines changed

Assets/Scripts/UrbanAirshipBehaviour.cs

Lines changed: 144 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ public class UrbanAirshipBehaviour : MonoBehaviour {
1212
void Awake () {
1313
Airship.Shared.TakeOff(new AirshipConfig() {
1414
defaultEnvironment = new ConfigEnvironment() {
15-
appKey = "APP_KEY",
16-
appSecret = "APP_SECRET",
15+
appKey = "VWDwdOFjRTKLRxCeXTVP6g",
16+
appSecret = "5Ifi5rYgTm2QHey9JkP0WA",
1717
logLevel = LogLevel.Verbose,
1818
},
1919
site = Site.US,
@@ -31,12 +31,13 @@ void Start () {
3131
// UAirship.Shared.AddTag (addTagOnStart);
3232
// }
3333

34-
// UAirship.Shared.OnPushReceived += OnPushReceived;
35-
// UAirship.Shared.OnChannelUpdated += OnChannelUpdated;
36-
// UAirship.Shared.OnDeepLinkReceived += OnDeepLinkReceived;
37-
// UAirship.Shared.OnPushOpened += OnPushOpened;
38-
// UAirship.Shared.OnInboxUpdated += OnInboxUpdated;
39-
// UAirship.Shared.OnShowInbox += OnShowInbox;
34+
Airship.Shared.OnPushReceived += OnPushReceived;
35+
Airship.Shared.OnPushOpened += OnPushOpened;
36+
Airship.Shared.OnChannelCreated += OnChannelCreated;
37+
Airship.Shared.OnDeepLinkReceived += OnDeepLinkReceived;
38+
Airship.Shared.OnInboxUpdated += OnInboxUpdated;
39+
Airship.Shared.OnShowInbox += OnShowInbox;
40+
Airship.Shared.OnPreferenceCenterDisplay += OnPreferenceCenterDisplay;
4041

4142
// PrivacyManager
4243
Debug.Log("Set Enabled features to none");
@@ -72,14 +73,14 @@ void Start () {
7273
// Channel
7374
Debug.Log("Channel ID: " + Airship.Shared.channel.GetChannelId());
7475

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-
// ));
76+
StartCoroutine(Airship.Shared.channel.WaitForChannelId(
77+
onComplete: (channelId) => {
78+
Debug.Log($"Channel ID received: {channelId}");
79+
},
80+
onError: (error) => {
81+
Debug.LogError($"Error getting channel ID: {error.Message}");
82+
}
83+
));
8384

8485
Airship.Shared.channel.EditTags().AddTag("unity_tag").Apply();
8586
Airship.Shared.channel.EditTags().AddTag("tag_to_remove_1").Apply();
@@ -96,14 +97,14 @@ void Start () {
9697

9798
Airship.Shared.channel.EditSubscriptionLists().Subscribe("unity_subscription_list").Apply();
9899
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-
// ));
100+
StartCoroutine(Airship.Shared.channel.GetSubscriptionLists(
101+
onComplete: (subscriptionLists) => {
102+
Debug.Log("Channel Subscription lists: " + string.Join(", ", subscriptionLists));
103+
},
104+
onError: (error) => {
105+
Debug.LogError("Error getting subscription lists: " + error.Message);
106+
}
107+
));
107108
Airship.Shared.channel.EditSubscriptionLists().Unsubscribe("unity_subscription_list_to_remove").Apply();
108109

109110
Airship.Shared.channel.EditAttributes().SetAttribute("teststring", "a_string").Apply();
@@ -139,15 +140,17 @@ void Start () {
139140
Airship.Shared.contact.EditSubscriptionLists().Subscribe("unity_subscription_list", SubscriptionScope.APP).Apply();
140141
Airship.Shared.contact.EditSubscriptionLists().Subscribe("unity_subscription_list_to_remove", SubscriptionScope.APP).Apply();
141142
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-
// ));
143+
StartCoroutine(Airship.Shared.contact.GetSubscriptionLists(
144+
onComplete: (subscriptionLists) => {
145+
Debug.Log("Contact Subscription lists:");
146+
foreach (var subscription in subscriptionLists) {
147+
Debug.Log($"List: {subscription.Key}, Scopes: {string.Join(", ", subscription.Value)}");
148+
}
149+
},
150+
onError: (error) => {
151+
Debug.LogError("Error getting subscription lists: " + error.Message);
152+
}
153+
));
151154

152155
// InApp
153156
Airship.Shared.inApp.SetPaused(true);
@@ -164,34 +167,34 @@ void Start () {
164167
// Debug.Log("Locale: " + Airship.Shared.locale.GetLocale());
165168

166169
// 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-
// ));
170+
StartCoroutine(Airship.Shared.messageCenter.RefreshInbox(
171+
onComplete: () => {
172+
Debug.Log("Refresh inbox complete");
173+
},
174+
onError: (error) => {
175+
Debug.LogError("Error refreshing inbox: " + error.Message);
176+
}
177+
));
175178

176179
Airship.Shared.messageCenter.SetAutoLaunchDefaultMessageCenter(true);
177180

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-
// ));
181+
StartCoroutine(Airship.Shared.messageCenter.GetUnReadCount(
182+
onComplete: (unreadCount) => {
183+
Debug.Log("Unread count: " + unreadCount);
184+
},
185+
onError: (error) => {
186+
Debug.LogError("Error getting unread count: " + error.Message);
187+
}
188+
));
186189

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-
// ));
190+
StartCoroutine(Airship.Shared.messageCenter.GetMessages(
191+
onComplete: (messages) => {
192+
Debug.Log("Messages: " + string.Join(", ", messages));
193+
},
194+
onError: (error) => {
195+
Debug.LogError("Error getting messages: " + error.Message);
196+
}
197+
));
195198

196199
Airship.Shared.messageCenter.Display(null);
197200
// Airship.Shared.messageCenter.ShowMessageCenter(null);
@@ -213,8 +216,6 @@ void Start () {
213216

214217
Airship.Shared.push.SetUserNotificationsEnabled(false);
215218
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());
218219

219220
StartCoroutine(Airship.Shared.push.EnableUserNotifications(
220221
new EnabledUserPushNotificationsArgs() {
@@ -253,78 +254,91 @@ void Start () {
253254
accentColor = "#FF0000",
254255
});
255256

257+
Airship.Shared.push.android.SetForegroundNotificationsEnabled(false);
258+
Debug.Log("Foreground notifications enabled: " + Airship.Shared.push.android.IsForegroundNotificationsEnabled());
256259
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());
260+
Debug.Log("Foreground notifications enabled after true: " + Airship.Shared.push.android.IsForegroundNotificationsEnabled());
261+
}
262+
263+
void OnDestroy () {
264+
Airship.Shared.OnPushReceived -= OnPushReceived;
265+
Airship.Shared.OnPushOpened -= OnPushOpened;
266+
Airship.Shared.OnChannelCreated -= OnChannelCreated;
267+
Airship.Shared.OnDeepLinkReceived -= OnDeepLinkReceived;
268+
Airship.Shared.OnInboxUpdated -= OnInboxUpdated;
269+
Airship.Shared.OnShowInbox -= OnShowInbox;
270+
Airship.Shared.OnPreferenceCenterDisplay -= OnPreferenceCenterDisplay;
271+
}
272+
273+
void OnPushReceived (PushMessage message) {
274+
Debug.Log ("Received push! " + message.Alert);
275+
276+
if (message.Extras != null) {
277+
foreach (KeyValuePair<string, string> kvp in message.Extras) {
278+
Debug.Log (string.Format ("Extras Key = {0}, Value = {1}", kvp.Key, kvp.Value));
279+
}
280+
}
260281
}
261282

262-
// void OnDestroy () {
263-
// UAirship.Shared.OnPushReceived -= OnPushReceived;
264-
// UAirship.Shared.OnChannelUpdated -= OnChannelUpdated;
265-
// UAirship.Shared.OnDeepLinkReceived -= OnDeepLinkReceived;
266-
// UAirship.Shared.OnPushOpened -= OnPushOpened;
267-
// }
268-
269-
// void OnPushReceived (PushMessage message) {
270-
// Debug.Log ("Received push! " + message.Alert);
271-
272-
// if (message.Extras != null) {
273-
// foreach (KeyValuePair<string, string> kvp in message.Extras) {
274-
// Debug.Log (string.Format ("Extras Key = {0}, Value = {1}", kvp.Key, kvp.Value));
275-
// }
276-
// }
277-
// }
278-
279-
// void OnPushOpened (PushMessage message) {
280-
// Debug.Log ("Opened Push! " + message.Alert);
281-
282-
// if (message.Extras != null) {
283-
// foreach (KeyValuePair<string, string> kvp in message.Extras) {
284-
// Debug.Log (string.Format ("Extras Key = {0}, Value = {1}", kvp.Key, kvp.Value));
285-
// }
286-
// }
287-
// }
288-
289-
// void OnChannelUpdated (string channelId) {
290-
// Debug.Log ("Channel updated: " + channelId);
291-
// }
292-
293-
// void OnDeepLinkReceived (string deeplink) {
294-
// Debug.Log ("Received deep link: " + deeplink);
295-
// }
296-
297-
// void OnInboxUpdated (uint messageUnreadCount, uint messageCount)
298-
// {
299-
// Debug.Log("Inbox updated - unread messages: " + messageUnreadCount + " total messages: " + messageCount);
300-
301-
// IEnumerable<InboxMessage>inboxMessages = UAirship.Shared.InboxMessages();
302-
// foreach (InboxMessage inboxMessage in inboxMessages)
303-
// {
304-
// Debug.Log("Message id: " + inboxMessage.id + ", title: " + inboxMessage.title + ", sentDate: " + inboxMessage.sentDate + ", isRead: " + inboxMessage.isRead + ", isDeleted: " + inboxMessage.isDeleted);
305-
// if (inboxMessage.extras == null)
306-
// {
307-
// Debug.Log("Extras is null");
308-
// }
309-
// else
310-
// {
311-
// foreach (KeyValuePair<string, string> entry in inboxMessage.extras)
312-
// {
313-
// Debug.Log("Message extras [" + entry.Key + "] = " + entry.Value);
314-
// }
315-
// }
316-
// }
317-
// }
318-
319-
// void OnShowInbox (string messageId)
320-
// {
321-
// if (messageId == null)
322-
// {
323-
// Debug.Log("OnShowInbox - show inbox");
324-
// }
325-
// else
326-
// {
327-
// Debug.Log("OnShowInbox - show message: messageId = " + messageId);
328-
// }
329-
// }
283+
void OnPushOpened (PushMessage message) {
284+
Debug.Log ("Opened Push! " + message.Alert);
285+
286+
if (message.Extras != null) {
287+
foreach (KeyValuePair<string, string> kvp in message.Extras) {
288+
Debug.Log (string.Format ("Extras Key = {0}, Value = {1}", kvp.Key, kvp.Value));
289+
}
290+
}
291+
}
292+
293+
void OnChannelCreated (string channelId) {
294+
Debug.Log ("Channel created: " + channelId);
295+
}
296+
297+
void OnDeepLinkReceived (string deeplink) {
298+
Debug.Log ("Received deep link: " + deeplink);
299+
}
300+
301+
void OnInboxUpdated (uint messageUnreadCount, uint messageCount)
302+
{
303+
Debug.Log("Inbox updated - unread messages: " + messageUnreadCount + " total messages: " + messageCount);
304+
305+
StartCoroutine(Airship.Shared.messageCenter.GetMessages(
306+
onComplete: (messages) => {
307+
foreach (InboxMessage inboxMessage in messages)
308+
{
309+
Debug.Log("Message id: " + inboxMessage.id + ", title: " + inboxMessage.title + ", sentDate: " + inboxMessage.sentDate + ", isRead: " + inboxMessage.isRead + ", isDeleted: " + inboxMessage.isDeleted);
310+
if (inboxMessage.extras == null)
311+
{
312+
Debug.Log("Extras is null");
313+
}
314+
else
315+
{
316+
foreach (KeyValuePair<string, string> entry in inboxMessage.extras)
317+
{
318+
Debug.Log("Message extras [" + entry.Key + "] = " + entry.Value);
319+
}
320+
}
321+
}
322+
},
323+
onError: (error) => {
324+
Debug.LogError("Error getting messages: " + error.Message);
325+
}
326+
));
327+
}
328+
329+
void OnShowInbox (string messageId)
330+
{
331+
if (messageId == null)
332+
{
333+
Debug.Log("OnShowInbox - show inbox");
334+
}
335+
else
336+
{
337+
Debug.Log("OnShowInbox - show message: messageId = " + messageId);
338+
}
339+
}
340+
341+
void OnPreferenceCenterDisplay (string preferenceCenterId) {
342+
Debug.Log ("Preference Center display - preferenceCenterId: " + preferenceCenterId);
343+
}
330344
}

Assets/UrbanAirship/Platforms/Airship.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ void OnPushOpened(string payload)
234234

235235
void OnDeepLinkReceived(string deeplink)
236236
{
237-
DeepLinkReceivedEventHandler handler = Shared.OnDeepLinkReceived;
237+
DeepLinkReceivedEventHandler handler = Airship.Shared.OnDeepLinkReceived;
238238

239239
if (handler != null)
240240
{
@@ -244,7 +244,7 @@ void OnDeepLinkReceived(string deeplink)
244244

245245
void OnChannelCreated(string channelId)
246246
{
247-
ChannelCreateEventHandler handler = Shared.OnChannelCreated;
247+
ChannelCreateEventHandler handler = Airship.Shared.OnChannelCreated;
248248

249249
if (handler != null)
250250
{
@@ -254,7 +254,7 @@ void OnChannelCreated(string channelId)
254254

255255
void OnInboxUpdated(string counts)
256256
{
257-
InboxUpdatedEventHandler handler = Shared.OnInboxUpdated;
257+
InboxUpdatedEventHandler handler = Airship.Shared.OnInboxUpdated;
258258

259259
MessageCounts messageCounts = JsonUtility.FromJson<MessageCounts>(counts);
260260

@@ -267,7 +267,7 @@ void OnInboxUpdated(string counts)
267267

268268
void OnShowInbox(string messageId)
269269
{
270-
ShowInboxEventHandler handler = Shared.OnShowInbox;
270+
ShowInboxEventHandler handler = Airship.Shared.OnShowInbox;
271271

272272
if (handler != null)
273273
{
@@ -284,7 +284,7 @@ void OnShowInbox(string messageId)
284284

285285
void OnPreferenceCenterDisplay(string preferenceCenterId)
286286
{
287-
PreferenceCenterDisplayEventHandler handler = Shared.OnPreferenceCenterDisplay;
287+
PreferenceCenterDisplayEventHandler handler = Airship.Shared.OnPreferenceCenterDisplay;
288288

289289
if (handler != null)
290290
{
@@ -294,7 +294,7 @@ void OnPreferenceCenterDisplay(string preferenceCenterId)
294294

295295
void OnAuthorizedSettingsChanged(AuthorizedNotificationSetting[] authorizedSettings)
296296
{
297-
AuthorizedSettingsChangedEventHandler handler = Shared.OnAuthorizedSettingsChanged;
297+
AuthorizedSettingsChangedEventHandler handler = Airship.Shared.OnAuthorizedSettingsChanged;
298298

299299
if (handler != null)
300300
{

0 commit comments

Comments
 (0)