Skip to content

Store device token to LoopSettings - #1494

Closed
gestrich wants to merge 1 commit into
LoopKit:devfrom
gestrich:missing-device-token
Closed

gestrich wants to merge 1 commit into
LoopKit:devfrom
gestrich:missing-device-token

Conversation

@gestrich

Copy link
Copy Markdown
Contributor

I was getting an error "Could not find deviceToken in loopSettings." error while trying to send push notifications. It appears the token gets set to LoopSettings.deviceToken but that value isn't stored to LoopSettings.

I'm not very familiar with this area of code or how it interacts with StoredSettings, which also includes a device token. So this may not be the appropriate fix.

@yodax

yodax commented Mar 22, 2021

Copy link
Copy Markdown

I was having the same issue. This fixes it for me. 👍

@ps2

ps2 commented Mar 26, 2021

Copy link
Copy Markdown
Collaborator

This is not the right fix. "Never cache the device token locally on the user's device." from https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1622958-application .

iOS reports the token to Loop at some point in the startup cycle. If Loop uploads settings before then, the token may be nil. The right fix is probably either prevent settings uploads until the token is reported, or find a way in NS to use the last non-nil token. Haven't really dug into this yet, but welcome anyone wanting to do so, considering the above.

@ps2 ps2 closed this Mar 26, 2021
@bill-foreflight

Copy link
Copy Markdown
Contributor

Ok cool. Thanks for looking into.

@gestrich

Copy link
Copy Markdown
Contributor Author

Further discussion on these comments in #1536

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants