Esempio n. 1
0
        private static void Main(string[] args)
        {
            var _test_phone = "IA";

            // IPHONE
            if (_test_phone == "IA")
            {
                var _apns   = new IosPushNotifyAPNs("<key-id>", "<team-id>", "<app-id>", "<key-file-path>");
                var _result = _apns
                              .JwtAPNsPush("<device-token>", "Json Web Token(JWT): Apple Push Notification Service(APNs)", 1, "<sound>")
                              .GetAwaiter()
                              .GetResult();

                Console.WriteLine($"result: {_result.success}, '{_result.message}'");
            }

            // ANDROID
            if (_test_phone == "AF")
            {
                var _fcm    = new DroidPushNotifyFCM("<server-api-key>", "<server-id>", "<alarm-tag>");
                var _result = _fcm
                              .SendNotification("<to>", "<priority>", "<title>", "<click-action>", "<message>", 1, "<icon-name>", "<color>")
                              .GetAwaiter()
                              .GetResult();

                Console.WriteLine($"result: {_result.success}, '{_result.message}'");
            }

            Console.ReadLine();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var _apns   = new IosPushNotifyAPNs("<key-id>", "<team-id>", "<app-id>", "<key-file-path>");
            var _result = _apns
                          .JwtAPNsPush("<device-token>", "Json Web Token(JWT): Apple Push Notification Service(APNs)", 1, "<sound>")
                          .GetAwaiter()
                          .GetResult();

            Console.WriteLine($"result: {_result.success}, '{_result.message}'");
            Console.ReadLine();
        }
Esempio n. 3
0
        private async Task <(bool success, string message)> SendNotification(AppDbContext ltctx, mMember member, string title, string message)
        {
            var _result = (success : false, message : "ok");

            try
            {
                var _notify_count = ltctx.tb_lion_notify
                                    .Where(n => n.LoginId == member.LoginId && n.IsRead == false)
                                    .Count();

                _notify_count++;

                if (member.DeviceType == "I")
                {
                    _result = await IosPushNotifyAPNs
                              .JwtAPNsPush(member.DeviceId, message, _notify_count, IosApnsSound);
                }
                else if (member.DeviceType == "A")
                {
                    _result = await DroidPushNotifyFCM
                              .SendNotification(member.DeviceId, "high", title, "PUSH_EVENT_ALARM", message, _notify_count, "alarm", "#d32121");
                }
                else if (member.DeviceType == "W")
                {
                }

                if (_result.success == false)
                {
                    member.DeviceType = "U";
                    member.DeviceId   = "";

                    await ltctx.SaveChangesAsync();
                }
            }
            catch (Exception ex)
            {
                _result.message = ex.Message;
            }

            return(_result);
        }