Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
64 lines (50 sloc) 1.84 KB
/*
Copyright 2018 Urban Airship and Contributors
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UrbanAirship;
public class UrbanAirshipBehaviour : MonoBehaviour {
public string addTagOnStart;
void Awake () {
UAirship.Shared.UserNotificationsEnabled = true;
}
void Start () {
if (!string.IsNullOrEmpty (addTagOnStart)) {
UAirship.Shared.AddTag (addTagOnStart);
}
UAirship.Shared.OnPushReceived += OnPushReceived;
UAirship.Shared.OnChannelUpdated += OnChannelUpdated;
UAirship.Shared.OnDeepLinkReceived += OnDeepLinkReceived;
UAirship.Shared.OnPushOpened += OnPushOpened;
}
void OnDestroy () {
UAirship.Shared.OnPushReceived -= OnPushReceived;
UAirship.Shared.OnChannelUpdated -= OnChannelUpdated;
UAirship.Shared.OnDeepLinkReceived -= OnDeepLinkReceived;
UAirship.Shared.OnPushOpened -= OnPushOpened;
}
void OnPushReceived (PushMessage message) {
Debug.Log ("Received push! " + message.Alert);
if (message.Extras != null) {
foreach (KeyValuePair<string, string> kvp in message.Extras) {
Debug.Log (string.Format ("Extras Key = {0}, Value = {1}", kvp.Key, kvp.Value));
}
}
}
void OnPushOpened (PushMessage message) {
Debug.Log ("Opened Push! " + message.Alert);
if (message.Extras != null) {
foreach (KeyValuePair<string, string> kvp in message.Extras) {
Debug.Log (string.Format ("Extras Key = {0}, Value = {1}", kvp.Key, kvp.Value));
}
}
}
void OnChannelUpdated (string channelId) {
Debug.Log ("Channel updated: " + channelId);
}
void OnDeepLinkReceived (string deeplink) {
Debug.Log ("Received deep link: " + deeplink);
}
}
You can’t perform that action at this time.