Skip to content

Commit

Permalink
better watch send message delay
Browse files Browse the repository at this point in the history
  • Loading branch information
kabouzeid committed Mar 21, 2022
1 parent e8e88f4 commit 3c3280d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions WatchIron Extension/PhoneConnectionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,10 @@ extension PhoneConnectionManager {
/// wrapper to send either via message or transfer, depending on what's available
private func sendUserInfo(userInfo: [String : Any]) {
guard isActivated else {
/// when the watch app is cold started via the phone, the session might not be activated yet, so try again in 1 second.
/// when the watch app is cold started via the phone, the session might not be activated yet, so try again after a short delay until the session is activated.
/// this is a kind of unclean workaround but it works very well
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
/// Note: smaller timeouts don't work so well. maybe rate limiting or something?
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
self.sendUserInfo(userInfo: userInfo)
}
return
Expand Down

0 comments on commit 3c3280d

Please sign in to comment.