zlZimon
zlZimon

Reputation: 2489

Can I have local push notifications which triggers or function in my app?

I want to use Local Push Notifications for iOS and Android based on the logic of the app. Basically I want to have a silent background notification every X ours which then triggers a function in my app which decides if the real notification will be displayed.

Can this be achieved with local push notification or do I need remote push notification?

[EDIT] Apparently my question is not clear enough so I add this example:

In my app I have a function which returns a string depending on some logic. I will start a local push notification every X hours which then calls this function to determine which string will be displayed.

Upvotes: 0

Views: 635

Answers (2)

Farhad Kabir
Farhad Kabir

Reputation: 61

You can use React Native Push Notification , use Scheduled Notifications ..

The have a example code like below

PushNotification.localNotificationSchedule({
    autoCancel: true,
    bigText:
      'This is local notification demo in React Native app. Only shown, when expanded.',
    subText: 'Local Notification Demo',
    title: 'Scheduled Notification Title',
    message: 'Scheduled Notification Message',
    vibrate: true,
    vibration: 500,
    playSound: true,
    soundName: 'default',
    actions: '["Yes", "No"]',
    date: new Date(Date.now() + 3 * 1000) // in 3 secs
  })

Upvotes: 0

fayeed
fayeed

Reputation: 2485

You could use react-native-background-task to start a background service that you can schedule to be called every x hours.

Upvotes: 1

Related Questions