Skip to content

Commit

Permalink
Calling the AWSAppSyncClientConfiguration connectionStateChangeHandle…
Browse files Browse the repository at this point in the history
…r on network availability changes and using .Online when the endpoint is reachable. (#30)
  • Loading branch information
stefanceriu authored and rohandubal committed Jun 28, 2018
1 parent 384d9dd commit 6be6d9e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion AWSAppSyncClient/AWSAppSyncClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ public class AWSAppSyncClient: NetworkConnectionNotification {
self.appSyncMQTTClient.allowCellularAccess = self.appSyncConfiguration.allowsCellularAccess
self.presignedURLClient = appSyncConfig.presignedURLClient
self.s3ObjectManager = appSyncConfig.s3ObjectManager
self.connectionStateChangeHandler = appSyncConfiguration.connectionStateChangeHandler

if let apiKeyAuthProvider = appSyncConfig.apiKeyAuthProvider {
self.httpTransport = AWSAppSyncHTTPNetworkTransport(url: self.appSyncConfiguration.url,
Expand Down Expand Up @@ -360,6 +361,7 @@ public class AWSAppSyncClient: NetworkConnectionNotification {

self.offlineMutationExecutor = MutationExecutor(networkClient: self.httpTransport!, appSyncClient: self, snapshotProcessController: SnapshotProcessController(endpointURL:self.appSyncConfiguration.url), fileURL: self.appSyncConfiguration.databaseURL)
networkStatusWatchers.append(self.offlineMutationExecutor!)
networkStatusWatchers.append(self)


NotificationCenter.default.addObserver(self, selector: #selector(checkForReachability(note:)), name: .reachabilityChanged, object: reachability)
Expand Down Expand Up @@ -503,7 +505,7 @@ public class AWSAppSyncClient: NetworkConnectionNotification {
func onNetworkAvailabilityStatusChanged(isEndpointReachable: Bool) {
var accessState: ClientNetworkAccessState = .Offline
if (isEndpointReachable) {
accessState = .Offline
accessState = .Online
}
self.connectionStateChangeHandler?.stateChanged(networkState: accessState)
}
Expand Down

0 comments on commit 6be6d9e

Please sign in to comment.