有没有办法console.log“推送通知”的令牌? 我尝试查看我的令牌,但我不知道该怎么做。 在我的代码中,我以天蓝色登录,我想获取“推送通知”的令牌 它对我不起作用。
我也在app.json中定义了
: "android": {
"googleServicesFile": "./google-services.json"
什么也没有发生,所以很困惑理解我的问题以获得此令牌。
import React from "react";
import { StyleSheet, Text, View } from "react-native";
import { AzureInstance, AzureLoginView } from "react-native-azure-ad-2";
// import { createDrawerNavigator } from '@react-navigation/drawer';
import PlacesNavigator from "./navigation/PlacesNavigator";
import { enableScreens } from "react-native-screens";
let token = await Notifications.getExpoPushTokenAsync(); //////HERE I TRY CONSOLE
console.log("this is the token :",token)
enableScreens();//function for more improve in screens movment
const credentials = {
client_id: "1234",
scope: "User.Read"
};
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
azureLoginObject: {},
loginSuccess: false
};
this.azureInstance = new AzureInstance(credentials);
this._onLoginSuccess = this._onLoginSuccess.bind(this);
}
_onLoginSuccess() {
this.azureInstance
.getUserInfo()
.then(result => {
this.setState({
loginSuccess: true,
azureLoginObject: result
});
console.log(result);
})
.catch(err => {
console.log(err);
});
}
render() {
if (!this.state.loginSuccess) {
return (
<AzureLoginView
azureInstance={this.azureInstance}
loadingMessage="Requesting access token"
onSuccess={this._onLoginSuccess}
/>
);
}
const { userPrincipalName, givenName } = this.state.azureLoginObject;
return <PlacesNavigator />;
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center"
},
text: {
textAlign: "center",
color: "#333333",
marginBottom: 5
}
});