当设备处于在线状态时,订阅工作良好,但是当设备离线并恢复在线状态时,订阅无法收听。
请检查以下情况- 有两个设备-设备A和设备B
do {
let userIs = Amplify.Auth.getCurrentUser()
subscriptionWatcher = try appSyncClient?.subscribe(subscription: OnCreateUserSubscription(), resultHandler: { (result, transaction, error) in
if let result = result {
print("Subscription triggered! " + (result.data!.onCreateUser!.firstName ?? "") + " " + (result.data!.onCreateUser!.lastName ?? ""))
}
if let error = error {
print(error.localizedDescription)
}
})
} catch {
print("Error starting subscription.")
}