【发布时间】:2021-06-22 09:14:47
【问题描述】:
我正在尝试注册连接 ionic、Firebase 和 Amazon SNS 的应用程序的每台设备。更具体地说,当用户登录包含以下内容的 TokenDTO 时:
- deviceToken: 字符串
- deviceUuid:字符串
- osType : string [用于区分iOS和Android]
必须发送到后端才能在 Amazon SNS 主题上注册 deviceToken。 我遇到的唯一问题是试图唯一标识一个 iOS 设备。在 Android 上,一切都按预期工作(使用 @ionic-native/unique-device-idd),但在 iOS 环境中使用时返回 null。有人可以帮忙吗?提前非常感谢您!
这是我的代码:
registerTokenOnSNS(tokenString): any {
let tokenDTO: TokenDTO = {
deviceToken: '',
imei: '',
osType: '',
};
if (this.platform.is('android')) {
tokenDTO.osType = 'Android';
} else {
tokenDTO.osType = 'iOS';
}
tokenDTO.deviceToken = tokenString;
tokenDTO.imei = this.device.uuid
return this.http.post<Response>(this.apiBaseUrl + '/register-endpoint', JSON.stringify(tokenDTO)).pipe(
map((result) => {
console.log('BE Received Token');
return result.body;
})
);
}
【问题讨论】:
-
请分享您的代码
-
@RaviAshara 我刚刚更新了我的问题。谢谢!
-
检查此链接“capacitorjs.com/docs/v2/apis/device”并使用来自
Device.getInfo的uuid -
你是在app.module.ts文件中导入
import { Device } from '@ionic-native/device/ngx';吗???
标签: ios ionic-framework ionic-native capacitor