internal static NotificationContent ToCrossPlatformNotificationContent(iOSNotificationContent iOSContent, out bool isRemote) { var content = new NotificationContent(); content.title = iOSContent.title; content.subtitle = iOSContent.subtitle; content.body = iOSContent.body; content.badge = iOSContent.badge; content.categoryId = iOSContent.categoryId; // Decode user info JSON. var userInfo = Json.Deserialize(iOSContent.userInfoJson) as Dictionary <string, object>; isRemote = false; if (userInfo.ContainsKey(IOS_USERINFO_ORIGIN_KEY) && userInfo[IOS_USERINFO_ORIGIN_KEY].Equals(IOS_USERINFO_EM_KEY)) { // This is a local notification created by us. // Extract the actual user info and assign it to the returned content. content.userInfo = userInfo[IOS_USERINFO_DATA_KEY] != null ? userInfo[IOS_USERINFO_DATA_KEY] as Dictionary <string, object> : new Dictionary <string, object>(); } else { // This is probably a remote notification created by APNS. // We'll just return the original userInfo. isRemote = userInfo.ContainsKey("aps"); content.userInfo = userInfo; } return(content); }
internal static iOSNotificationContent ToIOSNotificationContent(NotificationContent content) { // Encode user info into JSON, attach our own private info for recognization. var dict = new Dictionary <string, object>(); dict.Add(IOS_USERINFO_ORIGIN_KEY, IOS_USERINFO_EM_KEY); dict.Add(IOS_USERINFO_DATA_KEY, content.userInfo != null ? content.userInfo : new Dictionary <string, object>()); var iOSContent = new iOSNotificationContent(); iOSContent.title = content.title; iOSContent.subtitle = content.subtitle; iOSContent.body = content.body; iOSContent.badge = content.badge; iOSContent.userInfoJson = Json.Serialize(dict); // Determine the category for this notification. // If no valid category specified by the user, the default one is used. var category = EM_Settings.Notifications.GetCategoryWithId(content.categoryId); if (category == null) { category = EM_Settings.Notifications.DefaultCategory; } // Set the category ID. iOSContent.categoryId = category.id; // Extract sound settings from category. // Note that an empty sound name is seen as "using default sound" from native side. iOSContent.enableSound = category.sound != NotificationCategory.SoundOptions.Off; iOSContent.soundName = category.sound == NotificationCategory.SoundOptions.Custom ? category.soundName : null; return(iOSContent); }
internal static extern void _ScheduleRepeatLocalNotification(string identifier, ref iOSNotificationContent content, ref iOSDateComponents dateComponents, NotificationRepeat repeat);
internal static extern void _ScheduleLocalNotification(string identifier, ref iOSNotificationContent content, long delaySeconds);