Search code examples
ionic-frameworkionic3localnotification

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


I'm working on an ionic project.

If users don't open the application for a long time after downloading my app, I'd like to send them local notification. For example, I will send a notification if it does not open for 3 days. But I couldn't figure out how.

Can you help me?


Solution

  • You can use the following to send notifications from server:

    1. Create one table in your database to track user activities.

    2. Add columns as userId, lastActivity to store the time of the user's activity.

    3. Update the lastActivity column whenever the user opens the app.

    4. Write one scheduler which will run at a specific time every day.

    5. In the scheduler write a logic to get data from UserActivity table and compare the time stored in the table with your current time.

    6. If the time difference is greater than 3 days then send a notification to that user.

    For local notifications here is a way:

    Whenever user open's the app schedule the local notification of after 3 days from current date. ( Make sure to remove previously schedule notification before adding new one. )

    In this case if user open the app notification will reschedule automatically else notification will fire based on last schedule of it.