Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

Background Notifications in iOS with React Native

$
0
0

I am new to react native and am trying to create an app that allows user to listen to podcast that will be posted weekly via a database. Each time that a new podcast has been posted I would like the user to receive a background notification.

I have done some research and have been able to react local notifications that display whenever the app is opened (as shown below) I have been following this tutorial

https://wix.github.io/react-native-notifications/docs/localNotifications

Notiifications

Here is my code

import React from 'react';import {View} from 'react-native';import {Notifications} from 'react-native-notifications';import HomeStack from './app/nav';export default class App extends React.Component {  constructor(props) {    super(props);    Notifications.registerRemoteNotifications();    Notifications.events().registerNotificationReceivedForeground((notification: Notification, completion) => {      console.log(`Notification received in foreground: ${notification.title} : ${notification.body}`);      completion({alert: true, sound: false, badge: true});    });    Notifications.events().registerNotificationOpened((notification: Notification, completion) => {      console.log(`Notification opened: ${notification.payload}`);      completion();    });  }  someLocalNotification = Notifications.postLocalNotification({  body: 'Local notification!',  title: 'Local Notification!',  //sound: "chime.aiff",  category: 'SOME_CATEGORY',  userInfo: {},});render() {return <View style={{ flex: 1 }}><HomeStack /></View>}}

After doing some research I have found some tutorials to be a bit confusing or do not work. I was wondering what is the best way to create background notifications?


Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>