Esempio n. 1
0
        public static async void PushToEveryone(Confess confess)
        {
            string newbody = "";

            if (confess.Body.Length > 35)
            {
                newbody = $"{confess.Body.Substring(0, 30)}...";
            }
            else
            {
                newbody = confess.Body;
            }

            PushToAll dataToPush = new PushToAll()
            {
                notification_content = new NotificationContent()
                {
                    title       = "New Confession 📢!",
                    body        = confess.Body,
                    name        = Guid.NewGuid().ToString().Replace("-", ""),
                    custom_data = new Dictionary <string, string> {
                        { "key1", confess.Guid },
                        { "key2", confess.Owner_Guid },
                        { "type", "Confession" },
                        { "sender", confess.Owner_Guid }
                    }
                }
            };

            await PushToServer(dataToPush);
        }
Esempio n. 2
0
        private static async Task PushToServer(PushToAll push)
        {
            //push for Android
            await BaseClient.PostEntities("Confession/push/notifications", JsonConvert.SerializeObject(push));

            //push for Windows
            await BaseClient.PostEntities("Confession-UWP/push/notifications", JsonConvert.SerializeObject(push));
        }