public static IDictionary CreateNotificationPayload (CrossPlatformNotification _notification) { IDictionary _payloadDict = new Dictionary<string, object>(); IDictionary _apsDict = new Dictionary<string, object>(); iOSSpecificProperties _iosProperties = _notification.iOSProperties; string _keyForUserInfo = NPSettings.Notification.iOS.UserInfoKey; // Add alert info IDictionary _alertDict = new Dictionary<string, string>(); _alertDict[kBody] = _notification.AlertBody; _alertDict[kAction] = _iosProperties.AlertAction; _alertDict[kLaunchImage] = _iosProperties.LaunchImage; // Add alert, badge, sound to "aps" dictionary _apsDict[kAlert] = _alertDict; _apsDict[kBadge] = _iosProperties.BadgeCount; _apsDict[kSound] = _iosProperties.SoundName; // Add aps, user info, fire date, repeat interval to "payload" dictionary _payloadDict[kAPS] = _apsDict; _payloadDict[_keyForUserInfo] = _notification.UserInfo; _payloadDict[kFireDate] = _notification.FireDate.ToStringUsingZuluFormat(); _payloadDict[kRepeatIntervalKey] = (int)ConvertToCalendarUnit(_notification.RepeatInterval); return _payloadDict; }
public static IDictionary CreateNotificationPayload(CrossPlatformNotification _notification) { IDictionary _payloadDict = new Dictionary<string, object>(); IDictionary _apsDict = new Dictionary<string, object>(); iOSSpecificProperties _iosProperties = _notification.iOSProperties; // Alert IDictionary _alertDict = new Dictionary<string, string>(); _alertDict[kBody] = _notification.AlertBody; _alertDict[kAction] = _iosProperties.AlertAction; _alertDict[kLaunchImage] = _iosProperties.LaunchImage; _apsDict[kAlert] = _alertDict; // User info, fire date string _keyForUserInfo = NPSettings.Notification.iOS.UserInfoKey; _apsDict[_keyForUserInfo] = _notification.UserInfo; _apsDict[kFireDate] = _notification.FireDate.ToStringUsingZuluFormat(); // Sound, badge _apsDict[kBadge] = _iosProperties.BadgeCount; _apsDict[kSound] = _iosProperties.SoundName; // Add aps dictionary to payload _payloadDict[kAPS] = _apsDict; 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; // ContentTitle, TickerText, Tag if(_androidProperties != null) { _payloadDict[ContentTitleKey] = _androidProperties.ContentTitle; _payloadDict[TickerTextKey] = _androidProperties.TickerText; _payloadDict[TagKey] = _androidProperties.Tag; _payloadDict[kCustomSound] = _androidProperties.CustomSound; _payloadDict[kLargeIcon] = _androidProperties.LargeIcon; } 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; 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; }