Closed puremana closed 4 years ago
you should add Notifications.registerRemoteNotifications(); before registerRemoteNotificationsRegistered() it's ok for me and the new libr not use Notifications.requestPermissions(); you should change Notifications.ios.registerRemoteNotifications() (only ios) you should check platform;
you should add Notifications.registerRemoteNotifications(); before registerRemoteNotificationsRegistered() it's ok for me and the new libr not use Notifications.requestPermissions(); you should change Notifications.ios.registerRemoteNotifications() (only ios) you should check platform;
So you mean I should do this?
import React from 'react';
import { StatusBar, Platform } from 'react-native';
import { Notifications } from 'react-native-notifications';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
const Stack = createStackNavigator();
import Home from './screens/Home';
import Schedule from './screens/Schedule';
import firebase from '@react-native-firebase/app';
console.log(firebase.app().name);
class App extends React.Component {
constructor(props) {
super(props);
if (Platform.OS === 'ios') {
Notifications.ios.registerRemoteNotifications();
}
Notifications.events().registerRemoteNotificationsRegistered((event: Registered) => {
// TODO: Send the token to my server so it could send back push notifications...
console.log("Device Token Received", event.deviceToken);
});
Notifications.events().registerRemoteNotificationsRegistrationFailed((event: RegistrationError) => {
console.error(event);
});
you should add Notifications.registerRemoteNotifications(); before registerRemoteNotificationsRegistered() it's ok for me and the new libr not use Notifications.requestPermissions(); you should change Notifications.ios.registerRemoteNotifications() (only ios) you should check platform;
So you mean I should do this?
import React from 'react'; import { StatusBar, Platform } from 'react-native'; import { Notifications } from 'react-native-notifications'; import { NavigationContainer } from '@react-navigation/native'; import { createStackNavigator } from '@react-navigation/stack'; const Stack = createStackNavigator(); import Home from './screens/Home'; import Schedule from './screens/Schedule'; import firebase from '@react-native-firebase/app'; console.log(firebase.app().name); class App extends React.Component { constructor(props) { super(props); if (Platform.OS === 'ios') { Notifications.ios.registerRemoteNotifications(); } Notifications.events().registerRemoteNotificationsRegistered((event: Registered) => { // TODO: Send the token to my server so it could send back push notifications... console.log("Device Token Received", event.deviceToken); }); Notifications.events().registerRemoteNotificationsRegistrationFailed((event: RegistrationError) => { console.error(event); });
yes. and you add Notifications.registerRemoteNotifications() before registerRemoteNotificationsRegistered()
So this?
Notifications.registerRemoteNotifications();
if (Platform.OS === 'ios') {
Notifications.ios.registerRemoteNotifications();
}
That doesn't make much sense to me as I thought on android we don't need to request permission as it is automatically granted. So what would be the point of Notifications.registerRemoteNotifications();
in this case?
So this?
Notifications.registerRemoteNotifications(); if (Platform.OS === 'ios') { Notifications.ios.registerRemoteNotifications(); }
That doesn't make much sense to me as I thought on android we don't need to request permission as it is automatically granted. So what would be the point of
Notifications.registerRemoteNotifications();
in this case?
ok you needless add it
ok you needless add it
Sorry, I'm having a bit of trouble understanding. What do you mean by that?
Just trying to follow https://wix.github.io/react-native-notifications/docs/subscription
and I get
TypeError: _reactNativeNotifications.Notifications.requestPermissions is not a function
when I useNotifications.requestPermissions();
I'm receiving the device token just fine.
This is using
react-native run-android
on a Samsung J5Thanks!