PushNotations, которые не отображаются в AWS PinPoint из @ aws-ampify / pushnotification, не имеют методов configure, onRegeister или onNotification?

Я пытаюсь настроить PushNotiifactions на IOS, поддерживающем реакцию, с помощью AWS Amplify и PinPoint. Я выполнил инструкции AWS-Amplify, чтобы настроить push-уведомления на React. Собственная IOS, но я заметил, что я не получаю токен обратно после некоторой отладки, заметив, что импорт уведомлений не имеет методов configure, onRegeister или onNotification.

Мои зависимости:

"dependencies": {
"@aws-amplify/analytics": "^1.2.10",
"@aws-amplify/pushnotification": "^1.0.22",
"aws-amplify-react-native": "^2.1.7",
"react": "16.6.3",
"react-native": "0.58.3"
},

Мой App.js

import React, { Component } from "react";
import {
StyleSheet,
Text,
View,
PushNotificationIOS,
} from "react-native";

import aws_exports from "./aws-exports";
import Analytics from "@aws-amplify/analytics";
import PushNotification from "@aws-amplify/pushnotification";

// PushNotification need to work with Analytics
Analytics.configure(aws_exports);
Analytics.enable();
PushNotification.configure(aws_exports);

type Props = {};
export default class App extends Component {

componentDidMount(){
console.log('PN',PushNotification);
// get the notification data when notification is received
PushNotification.onNotification(notification => {
// Note that the notification object structure is different from Android and IOS
console.log("in app notification", notification);

  // required on iOS only (see fetchCompletionHandler docs: https://facebook.github.io/react-native/docs/pushnotificationios.html)
  notification.finish(PushNotificationIOS.FetchResult.NoData);
});

// get the registration token
PushNotification.onRegister(token => {
  console.log("in app registration", token);
});

// get the notification data when notification is opened
PushNotification.onNotificationOpened(notification => {
  console.log("the notification is opened", notification);
});
}
render() {
return (

Welcome to React Native!
To get started, edit App.js

);
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
alignItems: "center",
backgroundColor: "#F5FCFF"
},
welcome: {
fontSize: 20,
textAlign: "center",
margin: 10
},
instructions: {
textAlign: "center",
color: "#333333",
marginBottom: 5
}
});

person sourabh dadapure    schedule 31.01.2019    source источник


Ответы (1)


Эти методы PushNotification являются частью его прототипа, вы должны использовать что-то вроде этого:

console.log('PN', Object.getOwnPropertyNames(Object.getPrototypeOf(PushNotification)))

Что касается отсутствия токена в onRegister, вы тестируете его на реальном устройстве, а не на эмуляторе?

person Gabriela Thumé    schedule 26.02.2019