Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var keyId       = "";
            var teamId      = "";
            var bundleAppId = "";
            var keyPath     = "";
            var keyPassword = "";

            var deviceToken = "";

            var pusher = new ApnsPusher(keyId, teamId, bundleAppId, keyPath, keyPassword, ApnsEnvironment.Production);

            var notification = new ExtendedApnsNotification
            {
                Payload = new ApnsPayload
                {
                    Alert = new ApnsNotificationAlert
                    {
                        TitleLocalizationKey = "NotificationsService.NewMessage.Title",
                        BodyLocalizationKey  = "NotificationsService.NewMessage.BodySingle"
                    },
                    Badge          = 7,
                    MutableContent = 1
                },
                TxnId = ""
            };

            pusher.OnNotificationSuccess += OnNotificationSuccess;
            pusher.OnNotificationFailed  += OnNotificationFailed;

            Console.WriteLine("Sending notification...");
            pusher.SendNotificationAsync(notification, deviceToken);
        }
        static void Main(string[] args)
        {
            var keyId       = "";
            var teamId      = "";
            var bundleAppId = "";
            var keyPath     = "";
            var keyPassword = "";

            var deviceToken = "";

            NLog.LogManager.LoadConfiguration("NLog.config");
            var loggerFactory = new LoggerFactory();

            loggerFactory.AddNLog(new NLogProviderOptions {
                CaptureMessageTemplates = true, CaptureMessageProperties = true
            });
            var logger = loggerFactory.CreateLogger <ApnsPusher>();

            var pusher = new ApnsPusher(logger, keyId, teamId, bundleAppId, keyPath, keyPassword, ApnsEnvironment.Production);

            var notification = new ExtendedApnsNotification
            {
                Payload = new ApnsPayload
                {
                    Alert = new ApnsNotificationAlert
                    {
                        TitleLocalizationKey = "NotificationsService.NewMessage.Title",
                        BodyLocalizationKey  = "NotificationsService.NewMessage.BodySingle"
                    },
                    Badge          = 7,
                    MutableContent = 1
                },
                TxnId         = "",
                PushRecipient = ""
            };

            pusher.OnNotificationSuccess += OnNotificationSuccess;
            pusher.OnNotificationFailed  += OnNotificationFailed;

            Console.WriteLine("Sending notification...");
            pusher.SendNotificationAsync(notification, deviceToken);
            Console.ReadKey();
        }