我已经将One信号推送通知集成到我的本地应用程序中,但是当我按通知图标时,它将重定向到网页而不是我的应用程序。 我已经添加了所有必要的依赖项。
build.gradle:
manifestPlaceholders = [onesignal_app_id: "my-App-id",
onesignal_google_project_number: "Proect number"]
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
settings.gradle:-
include ':react-native-onesignal'
project(':react-native-onesignal').projectDir = new
File(rootProject.projectDir, '../node_modules/react-native-
onesignal/android')
这是我的代码功能:
onRegistered = (notifData) => {
console.log('Device had been registered for push notifications!',
notifData)
}
onIds = (device) => {
console.log('Device info: ', device)
}
changeMenuStyle = (data) => {
this.setState({ menuStyle: data.menuId })
}
handleDeepLink = (openResult) => {
const data = openResult.notification.payload.additionalData
alert(data)
this.props.setInitialNotification(openResult)
if (data && data.id) {
this.props.fetchPostById(data.id).then((post) => {
this.goToScreen('post', { post })
})
} else {
console.log('notification is invalid data')
}
}
goToScreen = (routeName, params, isReset = true) => {
const { navigator } = this.refs
navigator.dispatch({
type: 'Navigation/NAVIGATE',
routeName,
params,
})