安排本地通知 Xamarin Forms [英] Schedule local notification Xamarin Forms

查看:99
本文介绍了安排本地通知 Xamarin Forms的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Xamarin 中的本地通知有疑问.我需要能够在不同时间安排多个本地通知.

I have a question about local notification in Xamarin. I need to be able schedule more than one local notification in different hours.

我的意思是...

第一天
通知 1 - 上午 10 点 - 记住约会 1
通知 2 - 下午 02 点 - 记住约会 2
通知 3 - 晚上 08 点 - 记住约会 3

day 1
notification 1 - h 10 am - remember appointment 1
notification 2 - h 02 pm - remember appointment 2
notification 3 - h 08 pm - remember appointment 3

第二天
通知 1 - 上午 08 点 - 记住约会 1
通知 2 - 上午 11 点 - 记住约会 2
通知 3 - 下午 03 点 - 记住约会 3

day 2
notification 1 - h 08 am - remember appointment 1
notification 2 - h 11 am - remember appointment 2
notification 3 - h 03 pm - remember appointment 3

我阅读了这篇文章 但是 SetInexactRepeating 的实现在我的情况下不起作用,因为经理只记得一个通知(例如约会 1)而不是其他任何通知.

I read this article but the implementation with SetInexactRepeating doesn't work in my case because the manager rememeber only one notification (example appointment 1) and not anything else.

Xamarin 是否允许创建此方案?如果是,有人可以帮助我吗?

Does Xamarin allow to create this scenario? And if yes, can anyone help me?

推荐答案

为了在 Android 中拥有多个闹钟,每个闹钟都需要一个唯一的标识符.在您链接到的文章中,每次都使用零.这可能是你的问题.请参阅此答案,了解如何将唯一标识符传递给 getBroadcast 调用(注意传递 _id 而不是 0):

In order to have multiple alarms in Android, each one needs a unique identifier. In the article you linked to, zero is used each time. This could be your problem. See this answer for how to pass a unique identifier to the getBroadcast call (note passing _id instead of 0):

    Intent intent = new Intent(load.this, AlarmReceiver.class);
    final int _id = (int) System.currentTimeMillis();
    PendingIntent appIntent = PendingIntent.getBroadcast(this, _id, intent,PendingIntent.FLAG_ONE_SHOT);

这篇关于安排本地通知 Xamarin Forms的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆