internal static string ToJson(NotificationCategory[] categories) { if (categories == null) { return(Json.Serialize(new string[0])); } var jsonStrArray = new string[categories.Length]; for (int i = 0; i < categories.Length; i++) { jsonStrArray[i] = AndroidNotificationCategory.FromCrossPlatformCategory(categories[i]).ToJson(); } return(Json.Serialize(jsonStrArray)); }
internal static AndroidNotificationCategory FromCrossPlatformCategory(NotificationCategory category) { if (category == null) { return(null); } var androidCat = new AndroidNotificationCategory(); androidCat.id = category.id; androidCat.groupId = category.groupId; androidCat.name = category.name; androidCat.description = category.description; androidCat.importance = (int)category.importance; androidCat.enableBadge = category.enableBadge; androidCat.lights = (int)category.lights; androidCat.lightColor = category.lightColor.ToARGBHex(); androidCat.vibration = (int)category.vibration; androidCat.vibrationPattern = category.vibrationPattern; androidCat.lockScreenVisibility = (int)category.lockScreenVisibility; androidCat.sound = (int)category.sound; androidCat.soundName = System.IO.Path.GetFileNameWithoutExtension(category.soundName); // Android doesn't need file extension var actionList = new List <AndroidActionButton>(); if (category.actionButtons != null) { for (int i = 0; i < category.actionButtons.Length; i++) { actionList.Add(new AndroidActionButton() { id = category.actionButtons[i].id, title = category.actionButtons[i].title }); } } androidCat.actionButtons = actionList.ToArray(); return(androidCat); }