コード例 #1
0
    public override void OnReceive(Context context, Intent intent)
    {
        var title     = intent.GetStringExtra("title");
        var message   = intent.GetStringExtra("messsage");
        var channelId = intent.GetStringExtra("channelId");


        //var resultIntent = new Intent(context, typeof(MainActivity));


        //PendingIntent pending = PendingIntent.GetActivities(context, 0,
        //    new Intent[] { resultIntent },
        //    PendingIntentFlags.OneShot);


        ////////
        //NotificationCompat.Builder builder = new NotificationCompat.Builder(AndroidApp.Context, "kkk")
        //    .SetContentIntent(pending)
        //    .SetContentTitle(title)
        //    .SetContentText(message)
        //    .SetSmallIcon(Android.Resource.Drawable.SymDefAppIcon)
        //    .SetDefaults((int)NotificationDefaults.Sound | (int)NotificationDefaults.Vibrate);

        ///////


        // var notification = builder.Build();

        DateTime now                       = DateTime.Now;
        var      notificationID            = now.Millisecond;
        AndroidNotificationManager manager = (AndroidNotificationManager)DependencyService.Get <INotificationManager>();

        Console.WriteLine("AlarmReceiver 222");
        manager.ScheduleNotification2(title, message);
    }
コード例 #2
0
        private void RegisterDependencies()
        {
            var notification         = new AndroidNotificationManager();
            var androidLoginProvider = new AndroidLoginProvider();

            DependencyService.RegisterSingleton <INotificationManager>(notification);
            DependencyService.RegisterSingleton <ILoginProvider>(androidLoginProvider);
        }
コード例 #3
0
        public int ScheduleNotification(int id)
        {
            if (!channelInitialized)
            {
                CreateNotificationChannel();
            }

            Intent intent = new Intent(context, typeof(MainActivity));

            var sqliteController = new AndroidSQLite();
            var dbPath           = sqliteController.GetPlatformDBPath("translations.db3");
            var connection       = sqliteController.GetConnection(dbPath);

            var alarmStorage = new AlarmStorage(context);
            var alarm        = alarmStorage.GetAlarmById(id);

            string difficulty;

            if (alarm == null || alarm.Difficulty == null)
            {
                difficulty = "Advanced";
            }
            else
            {
                difficulty = alarm.Difficulty;
            }

            Android.Util.Log.Verbose("notifyFilter", $"SCHEDULED DIFF TRIGGERED {difficulty}"); // adb logcat -s notifyFilter

            var randomTranslation = connection.Query <ItemTranslation>($"SELECT * FROM ItemTranslation WHERE Difficulty = '{difficulty}' ORDER BY RANDOM() LIMIT 1").First();

            PendingIntent pendingIntent = PendingIntent.GetActivity(context, id, intent, PendingIntentFlags.OneShot);

            var notification = AndroidNotificationManager.BuildNotification(context, pendingIntent, randomTranslation.German, randomTranslation.English);

            StartForeground(id, notification);

            ReceiveNotification(randomTranslation);

            var util = new AlarmUtil(context);

            if (alarm != null)
            {
                util.ScheduleAlarm(alarm);
                Android.Util.Log.Verbose("notifyFilter", $"Rescheduled {alarm.Id}"); // adb logcat -s notifyFilter
            }

            StopForeground(false);

            return(id);
        }
コード例 #4
0
    public void sendRequest()
    {
        var data = new Dictionary <string, object>();

        data["requesterUid"]  = user.UserId;
        data["accepterEmail"] = friendReq.text;
        var function = Firebase.Functions.FirebaseFunctions.DefaultInstance.GetHttpsCallable("sendFriendRequest");

        function.CallAsync(data);

        /* string key = reference.Child("users").Child(friendReq.text.Replace('.', ',')).Child("invites").Push().Key;
         * reference.Child("users").Child(friendReq.text.Replace('.', ',')).Child("invites").Child(key).SetValueAsync(user.Email); */
        AndroidNotificationManager.sentFriendRequestNotification(friendReq.text);
        friendReq.text = "";
    }