public static IDictionary CreateNotificationPayload(CrossPlatformNotification _notification) { IDictionary _payloadDict = new Dictionary <string, object>(); AndroidSpecificProperties _androidProperties = _notification.AndroidProperties; // Alert _payloadDict[ContentTextKey] = _notification.AlertBody; // User info, fire date _payloadDict[UserInfoKey] = _notification.UserInfo; _payloadDict[kFireDate] = _notification.FireDate.ToJavaTimeFromDateTime(); _payloadDict[kRepeatIntervalKey] = (int)_notification.RepeatInterval; _payloadDict[kCustomSound] = _notification.SoundName; // ContentTitle, TickerText, Tag if (_androidProperties != null) { _payloadDict[ContentTitleKey] = _androidProperties.ContentTitle; _payloadDict[TickerTextKey] = _androidProperties.TickerText; _payloadDict[TagKey] = _androidProperties.Tag; _payloadDict[kLargeIcon] = _androidProperties.LargeIcon; if (string.IsNullOrEmpty(_notification.SoundName)) //This fallback will be removed in upcoming version. { #pragma warning disable _payloadDict[kCustomSound] = _androidProperties.CustomSound; #pragma warning enable } } return(_payloadDict); }
public static IDictionary CreateNotificationPayload(CrossPlatformNotification _notification) { IDictionary _payloadDict = new Dictionary <string, object>(); AndroidSpecificProperties _androidProperties = _notification.AndroidProperties; // Alert _payloadDict[ContentTextKey] = _notification.AlertBody; // User info, fire date _payloadDict[UserInfoKey] = _notification.UserInfo; _payloadDict[kFireDate] = _notification.FireDate.ToJavaTimeFromDateTime(); _payloadDict[kRepeatIntervalKey] = (int)_notification.RepeatInterval; _payloadDict[kCustomSound] = _notification.SoundName; // ContentTitle, TickerText, Tag if (_androidProperties != null) { _payloadDict[ContentTitleKey] = _androidProperties.ContentTitle; _payloadDict[TickerTextKey] = _androidProperties.TickerText; _payloadDict[TagKey] = _androidProperties.Tag; _payloadDict[kLargeIcon] = _androidProperties.LargeIcon; _payloadDict[kBadgeCount] = _androidProperties.BadgeCount; } return(_payloadDict); }
internal CrossPlatformNotification(IDictionary _jsonDict) { // Get alert body AlertBody = _jsonDict.GetIfAvailable <string>(kAlertBodyKey); // Get fire date, repeat interval string _fireDateStr = _jsonDict.GetIfAvailable <string>(kFireDateKey); if (!string.IsNullOrEmpty(_fireDateStr)) { FireDate = _fireDateStr.ToZuluFormatDateTimeLocal(); } RepeatInterval = _jsonDict.GetIfAvailable <eNotificationRepeatInterval>(kRepeatIntervalKey); // Get user info UserInfo = _jsonDict[kUserInfoKey] as IDictionary; // Get sound name SoundName = _jsonDict.GetIfAvailable <string>(kSoundNameKey); // Get iOS specific properties, if included if (_jsonDict.Contains(kiOSPropertiesKey)) { iOSProperties = new iOSSpecificProperties(_jsonDict[kiOSPropertiesKey] as IDictionary); } // Get Android specific properties, if included if (_jsonDict.Contains(kAndroidPropertiesKey)) { AndroidProperties = new AndroidSpecificProperties(_jsonDict[kAndroidPropertiesKey] as IDictionary); } }
public OneSignalNotificationPayload(string _message, Dictionary <string, object> _additionalData) { // Set properties this.AlertBody = _message; this.iOSProperties = new iOSSpecificProperties(); this.AndroidProperties = new AndroidSpecificProperties(); this.SoundName = _additionalData.GetIfAvailable <string>(kSoundKey); // Extract other properties from data dictionary if (_additionalData == null) { return; } // iOS specific properties iOSSpecificProperties _iOSProperties = this.iOSProperties; _iOSProperties.HasAction = _additionalData.ContainsKey(kActionButtonsKey); // Android specific properties AndroidSpecificProperties _androidProperties = this.AndroidProperties; _androidProperties.ContentTitle = _additionalData.GetIfAvailable <string>(kTitleKey); // Get user info dictionary by removing used property keys IDictionary _userInfoDict = new Dictionary <string, object>(_additionalData); _userInfoDict.Remove(kTitleKey); this.UserInfo = _userInfoDict; }
public AndroidNotificationPayload(IDictionary _payloadDict) { AndroidProperties = new AndroidSpecificProperties(); // Alert if (_payloadDict.Contains(NPSettings.Notification.Android.ContentTextKey)) { //Check here which key is being received. Console.Log(Constants.kDebugTag, "[BillingTransaction] " + _payloadDict.ToJSON());//TODO object _alertUnknownType = _payloadDict[ContentTextKey] as object; // String type if ((_alertUnknownType as string) != null) { AlertBody = _alertUnknownType as string; } } if (_payloadDict.Contains(UserInfoKey)) UserInfo = _payloadDict[UserInfoKey] as IDictionary; // Fire date long _secsFromNow = _payloadDict.GetIfAvailable<long>(kFireDate); FireDate = _secsFromNow.ToDateTimeFromJavaTime(); // Sound, Badge AndroidProperties.ContentTitle = _payloadDict.GetIfAvailable<string>(ContentTitleKey); AndroidProperties.TickerText = _payloadDict.GetIfAvailable<string>(TickerTextKey); AndroidProperties.Tag = _payloadDict.GetIfAvailable<string>(TagKey); //Added in 1.03 AndroidProperties.CustomSound = _payloadDict.GetIfAvailable<string>(kCustomSound); AndroidProperties.LargeIcon = _payloadDict.GetIfAvailable<string>(kLargeIcon); }
public CrossPlatformNotification() { AlertBody = null; UserInfo = null; iOSProperties = null; AndroidProperties = null; }
public CrossPlatformNotification() { AlertBody = null; UserInfo = null; RepeatInterval = eNotificationRepeatInterval.NONE; iOSProperties = null; AndroidProperties = null; }
public AndroidNotificationPayload(IDictionary _payloadDict) { AndroidProperties = new AndroidSpecificProperties(); // Alert if (_payloadDict.Contains(NPSettings.Notification.Android.ContentTextKey)) { //Check here which key is being received. VoxelBusters.DebugPRO.Console.Log(Constants.kDebugTag, "[AndroidNotificationPayload] " + _payloadDict.ToJSON()); //TODO object _alertUnknownType = _payloadDict[ContentTextKey] as object; // String type if ((_alertUnknownType as string) != null) { AlertBody = _alertUnknownType as string; } } if (_payloadDict.Contains(UserInfoKey)) { UserInfo = _payloadDict[UserInfoKey] as IDictionary; } // Fire date long _secsFromNow = _payloadDict.GetIfAvailable <long>(kFireDate); FireDate = _secsFromNow.ToDateTimeFromJavaTime(); if (_payloadDict.Contains(kRepeatIntervalKey)) { RepeatInterval = (eNotificationRepeatInterval)_payloadDict.GetIfAvailable <int>(kRepeatIntervalKey); } SoundName = _payloadDict.GetIfAvailable <string>(kCustomSound); AndroidProperties.ContentTitle = _payloadDict.GetIfAvailable <string>(ContentTitleKey); AndroidProperties.TickerText = _payloadDict.GetIfAvailable <string>(TickerTextKey); AndroidProperties.Tag = _payloadDict.GetIfAvailable <string>(TagKey); AndroidProperties.LargeIcon = _payloadDict.GetIfAvailable <string>(kLargeIcon); AndroidProperties.BadgeCount = _payloadDict.GetIfAvailable <int>(kBadgeCount); }
internal CrossPlatformNotification(IDictionary _jsonDict) { // Get alert body AlertBody = _jsonDict.GetIfAvailable<string>(kAlertBodyKey); // Get fire date string _fireDateStr = _jsonDict.GetIfAvailable<string>(kFireDateKey); if (!string.IsNullOrEmpty(_fireDateStr)) FireDate = _fireDateStr.ToDateTimeLocalUsingZuluFormat(); // Get user info UserInfo = _jsonDict[kUserInfoKey] as IDictionary; // Get iOS specific properties, if included if (_jsonDict.Contains(kiOSPropertiesKey)) iOSProperties = new iOSSpecificProperties(_jsonDict[kiOSPropertiesKey] as IDictionary); // Get Android specific properties, if included if (_jsonDict.Contains(kAndroidPropertiesKey)) AndroidProperties = new AndroidSpecificProperties(_jsonDict[kAndroidPropertiesKey] as IDictionary); }
public AndroidNotificationPayload(IDictionary _payloadDict) { AndroidProperties = new AndroidSpecificProperties(); // Alert if (_payloadDict.Contains(NPSettings.Notification.Android.ContentTextKey)) { //Check here which key is being received. Console.Log(Constants.kDebugTag, "[BillingTransaction] " + _payloadDict.ToJSON()); //TODO object _alertUnknownType = _payloadDict[ContentTextKey] as object; // String type if ((_alertUnknownType as string) != null) { AlertBody = _alertUnknownType as string; } } if (_payloadDict.Contains(UserInfoKey)) { UserInfo = _payloadDict[UserInfoKey] as IDictionary; } // Fire date long _secsFromNow = _payloadDict.GetIfAvailable <long>(kFireDate); FireDate = _secsFromNow.ToDateTimeFromJavaTime(); // Sound, Badge AndroidProperties.ContentTitle = _payloadDict.GetIfAvailable <string>(ContentTitleKey); AndroidProperties.TickerText = _payloadDict.GetIfAvailable <string>(TickerTextKey); AndroidProperties.Tag = _payloadDict.GetIfAvailable <string>(TagKey); //Added in 1.03 AndroidProperties.CustomSound = _payloadDict.GetIfAvailable <string>(kCustomSound); AndroidProperties.LargeIcon = _payloadDict.GetIfAvailable <string>(kLargeIcon); }
public OneSignalNotificationPayload(OSNotificationPayload _payload) { // iOS specific properties iOSSpecificProperties _iOSProperties = new iOSSpecificProperties(); _iOSProperties.HasAction = (_payload.actionButtons != null) && (_payload.actionButtons.Count > 0); // Android specific properties AndroidSpecificProperties _androidProperties = new AndroidSpecificProperties(); _androidProperties.ContentTitle = _payload.title; // Get user info dictionary by removing used property keys IDictionary _userInfoDict = new Dictionary <string, object>(_payload.additionalData != null ? _payload.additionalData : new Dictionary <string, object>()); _userInfoDict.Remove(kTitleKey); // Set properties this.AlertBody = _payload.body; this.iOSProperties = _iOSProperties; this.AndroidProperties = _androidProperties; this.SoundName = _payload.sound; this.UserInfo = _userInfoDict; }
public CrossPlatformNotification () { AlertBody = null; UserInfo = null; RepeatInterval = eNotificationRepeatInterval.NONE; SoundName = null; iOSProperties = null; AndroidProperties = null; }