【问题标题】:How to subscribe to multiple events in an AWS AppSync client?如何订阅 AWS AppSync 客户端中的多个事件?
【发布时间】:2018-12-28 22:39:14
【问题描述】:

我们目前正尝试在我们的 Android 客户端中实现多个订阅,并面临一些非常奇怪的行为。

一个订阅运行良好。但是当我们订阅另一个事件时,似乎后者阻止了第一个订阅。 问题是,有任何示例涵盖两个或多个订阅。

这是我们目前想出的:

private AppSyncSubscriptionCall orderSubscriptionWatcher;
private AppSyncSubscriptionCall receiptSubscriptionWatcher;

private void subscribeToEvents() {
  AWSAppSyncClient awsAppSyncClient = ClientFactory.getInstance(this.getApplicationContext());

  AddedOrderSubscription addedOrderSubscription = AddedOrderSubscription.builder().build();
  orderSubscriptionWatcher = awsAppSyncClient.subscribe(addedOrderSubscription);
  orderSubscriptionWatcher.execute(orderSubCallback);

  AddedReceiptSubscription addedReceiptSubscription = AddedReceiptSubscription.builder().build();
  receiptSubscriptionWatcher = awsAppSyncClient.subscribe(addedReceiptSubscription);
  receiptSubscriptionWatcher.execute(receiptSubCallback);
}

任何想法如何解决这个问题?

【问题讨论】:

    标签: android graphql aws-appsync


    【解决方案1】:

    您是否使用 API 密钥?如果是这样,您将需要使用不同的身份验证方法。

    【讨论】:

    • 是的,我们通过 api_key 使用身份验证。所以这个功能永远不会被支持?
    • 您可以在 AppSync 中使用 API 密钥打开多个订阅,但该服务在您使用 API 密钥时没有可跟踪的身份,因此您需要在应用中本地管理多个订阅.这在今天的 JS SDK 中完成,但目前在 iOS/Android SDK 中没有。这些平台也在研究中。
    猜你喜欢
    • 2020-08-31
    • 2019-04-03
    • 2018-12-20
    • 2020-03-21
    • 1970-01-01
    • 2021-03-11
    • 2020-08-30
    • 2018-09-30
    • 2019-09-16
    相关资源
    最近更新 更多