如何在用户未打开应用程序时发送通知?

How to send notification when users don't open app?

我正在做一个离子项目。

如果用户下载我的应用后很长时间没有打开应用,我想向他们发送本地通知。 比如3天不开门我会发通知。但是我想不通。

你能帮帮我吗?

You can create a system in which you track user like , 
if user's opens your App then you must update true value for that user with time in your database and now you can compare current time with user's time value and if its more then 3 days you must send notification to that user.

您可以使用以下方式从服务器发送通知:

  1. 在您的数据库中创建一个 table 来跟踪用户活动。

  2. 添加列作为userId,lastActivity 来存储用户activity的时间。

  3. 每当用户打开应用程序时更新 lastActivity 列。

  4. 编写一个调度程序,每天在特定时间 运行。

  5. 在调度器中写一个逻辑从 UserActivity table 中获取数据,并将 table 中存储的时间与您当前的时间进行比较。

  6. 如果时差大于 3 天,则向该用户发送通知。

对于本地通知,这里有一个方法:

每当用户打开应用程序时,都会在从当前日期起 3 天后安排本地通知。 (确保在添加新通知之前删除之前安排的通知。)

在这种情况下,如果用户打开应用程序,通知将自动重新安排,否则通知将根据上次的安排触发。