Exemplo n.º 1
0
        public TopicUnicastMessage(FcmMessageOptions options, Topic topic, NotificationPayload notification)
            : base(options, notification)

        {
            if (topic == null)
            {
                throw new ArgumentNullException("topic");
            }
            To = topic.getTopicPath();
        }
Exemplo n.º 2
0
 public FcmMessage(FcmMessageOptions options, NotificationPayload notification)
 {
     Notification     = notification;
     CollapseKey      = options.CollapseKey;
     Priority         = options.PriorityEnum;
     ContentAvailable = options.ContentAvailable;
     DelayWhileIdle   = options.DelayWhileIdle;
     TimeToLive       = options.TimeToLive;
     DryRun           = options.DryRun;
 }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            // Read the API Key from a File, which is not under Version Control:
            var settings = new FileBasedFcmClientSettings("/Users/bytefish/api.key");

            // Construct the Client:
            using (var client = new FcmClient(settings))
            {
                // Construct the Data Payload to send:
                var data = new
                {
                    A = new
                    {
                        a = 1,
                        b = 2
                    },
                    B = 2,
                };

                // Options for the Message:
                var options = FcmMessageOptions.Builder()
                              .setTimeToLive(TimeSpan.FromDays(1))
                              .Build();

                // The Message should be sent to the News Topic:
                var message = new TopicUnicastMessage <dynamic>(options, new Topic("news"), data);

                // Finally send the Message and wait for the Result:
                CancellationTokenSource cts = new CancellationTokenSource();

                // Send the Message and wait synchronously:
                var result = client.SendAsync(message, cts.Token).GetAwaiter().GetResult();

                // Print the Result to the Console:
                System.Console.WriteLine("Result = {0}", result);
            }
        }
Exemplo n.º 4
0
 public FcmMulticastMessage(FcmMessageOptions options, IList <string> registrationIds, NotificationPayload notification)
     : base(options, notification)
 {
     RegistrationIds = registrationIds;
 }
Exemplo n.º 5
0
        public TopicMulticastMessage(FcmMessageOptions options, TopicList topicList, NotificationPayload notification)
            : base(options, notification)

        {
            Condition = topicList.GetTopicsCondition();
        }
Exemplo n.º 6
0
 public FcmUnicastMessage(FcmMessageOptions options, String to, NotificationPayload notification)
     : base(options, notification)
 {
     To = to;
 }