我正在使用 AWS Cognito 登录并获取临时凭证。我在浏览器的 Ionic 应用程序中尝试了 PubSub API,它对于设备影子更新工作正常。现在我已经用 Java 为 android 编写了代码,但 MqttManager 一直在重新连接。
这是 Ionic 4 + Capacitor 插件中的原生代码
@PluginMethod()
public void Init(PluginCall call)
{
String clientId = call.getString("clientId", null);
if(clientId == null)
{
UUID uuid = UUID.randomUUID();
clientId = uuid.toString();
}
mqttManager = new AWSIotMqttManager
(
clientId,
"m6jklghidefabc-ats.iot.us-west-1.amazonaws.com"
);
String id = AWSMobileClient.getInstance().getIdentityId();
if(id == null)
{
call.reject("Could not get identity id");
return;
}
else
{
Log.i("Plugin===", id);
}
//
// Connect MQTT Manager
//
try
{
MqttPlugin …Run Code Online (Sandbox Code Playgroud)