ios - AWS-amplify/pushnotification 未将地址设置为 endpoint_id
问题描述
我的应用程序为 Android 和 IOS 实现推送通知,众所周知,为了发送推送通知,aws-amplify/pinpoint 服务使用“地址”,该地址是通过在第一次安装或用户身份验证期间分配给应用程序的 endpoint_id 收集的。但是,当我登录 android 时,会正确创建寄存器,并且在 IOS 的情况下分配的地址不会发生相同的情况。下面我展示文件。知道如何将“地址”通知给 IOS 吗?欢迎任何帮助。谢天谢地。
index.js
import { Alert, AppRegistry, Platform, Linking } from 'react-native'
import App from './app/App'
import { name as appName } from './app.json'
import { requestTrackingPermission } from 'react-native-tracking-transparency'
import Amplify from 'aws-amplify'
import PushNotification from '@aws-amplify/pushnotification'
import { PushNotificationIOS } from '@react-native-community/push-notification-ios'
import config from './aws-exports'
if (Platform.OS === 'android' || Platform.OS === 'ios' || Platform.OS === 'macos') {
Amplify.configure(config)
Amplify.Logger.LOG_LEVEL = 'DEBUG'
// 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://github.com/react-native-community/push-notification-ios#finish)
if (Platform.OS === 'ios' || Platform.OS === 'macos')
notification.finish(PushNotificationIOS.FetchResult.NoData)
})
// get the registration token
// This will only be triggered when the token is generated or updated.
PushNotification.onRegister((token) => {
console.log('in app registration', token);
})
}
AppRegistry.registerComponent(appName, () => App)
包.json
"dependencies": {
"@react-native-async-storage/async-storage": "^1.15.5",
"@react-native-community/masked-view": "^0.1.10",
"@react-native-community/netinfo": "^5.9.10",
"@react-native-community/toolbar-android": "^0.1.0-rc.2",
"@react-native-community/push-notification-ios": "^1.8.0",
"@react-native-firebase/analytics": "^10.5.1",
"@react-native-firebase/app": "^10.5.0",
"@react-native-firebase/crashlytics": "^10.5.1",
"@aws-amplify/pushnotification": "^3.2.32",
"amazon-cognito-identity-js": "^4.5.7",
"aws-amplify": "^3.2.0",
"aws-amplify-react-native": "^4.3.0".
...
}
JSON AWS-GET-ENDPOINT
{
"EndpointsResponse": {
"Item": [
{
// sould have an "address": "<token>" here!
"ApplicationId": "<my_application_id>",
"Attributes": {},
"ChannelType": "GCM",
"CohortId": "11",
"CreationDate": "2021-08-11T23:40:29.708Z",
"Demographic": {
"AppVersion": "android/30",
"ModelVersion": "30",
"Platform": "android"
},
"EffectiveDate": "2021-08-12T00:03:30.696Z",
"EndpointStatus": "ACTIVE",
"Id": "<my_endpoint_id>",
"Location": {},
"Metrics": {},
"OptOut": "NONE",
"RequestId": "<my_request_id>",
"User": {
"UserAttributes": {
},
"UserId": "<my_id>"
}
}
]
}
}
解决方案
推荐阅读
- sql - SQL 重叠语句
- mjml - MJML 字体问题 - mj-font 未在实际电子邮件模板中加载字体
- c++ - 使用 c++2b 编码不可知的解析
- amazon-web-services - how to install Apache superset on a AWS ECS container
- perl - in perl, why does sprintf(Dumper \%hash) throw a warning when the hash contains a long string?
- html - Select doesn't display patched value
- java - How can I get POI to interpret a large Excel cell as a long?
- reporting-services - SSRS showing a blank column on a column grouping that is not in the design tab
- r - Calculate length of multiple lists within a data.table
- clickhouse - IPv4-mapped IPv6 address parsing