public async Task <bool> Send(string namedUserId, MessagePush pushData, long queueId)
        {
            var jData = JObject.FromObject(pushData);
            var paramaterDictionary = new Dictionary <string, string>();

            paramaterDictionary.Add("Id", pushData.Id.ToString());
            paramaterDictionary.Add("Type", pushData.Type);

            var result = await client.PushAsync(pushData.Title, new List <UrbanAirSharp.Type.DeviceType>() { UrbanAirSharp.Type.DeviceType.Ios, UrbanAirSharp.Type.DeviceType.Android }, null, new List <BaseAlert>()
            {
                new AndroidAlert()
                {
                    Alert          = pushData.Title,
                    DelayWhileIdle = true,
                    GcmTimeToLive  = 3600,
                    Extras         = paramaterDictionary
                },
                new IosAlert()
                {
                    Alert            = pushData.Title,
                    ContentAvailable = true,
                    ApnsTimeToLive   = 3600,
                    Extras           = paramaterDictionary
                }
            }, new Audience(UrbanAirSharp.Type.AudienceType.NamedUser, namedUserId));

            return(result.Ok);
        }
Exemplo n.º 2
0
 public static async Task SendPushMessage(AppUserMessage item, DateTime?time = null)
 {
     if (time.HasValue)
     {
         await Push.Instance.SendTimed(item.DeviceOwner.NamedUserId, MessagePush.MessageData(item), item.Id, time.Value);
     }
     else
     {
         await Push.Instance.Send(item.DeviceOwner.NamedUserId, MessagePush.MessageData(item), item.Id);
     }
 }
 public static void SendPushMessage(AppP2PMessage item)
 {
     Push.Instance.Send(item.DeviceOwner.NamedUserId, MessagePush.MessageData(item), item.Id);
 }