You create a channel, send it to your server and then the server can send until it fails (the channel Uri expires or there's an error). At which point the app needs to create a new ChannelUri and then UPDATE the value stored for that app/device on the server. The server will then be able to send notifications.
Some important points
- When a new channel Uri is requested for one that is still valid you'll get the same one back.
- When your ask for a new channel uri and the current one has expired, you'll normally get the same uri returned but the channel will be made live again.
- There is no way to know if a channel has expired from within an app without running code like your registerPushChannel method. (Unless you track this on your backend and the app queries the backend.)
- There is no way to tell the app that a channel has expired, or tell the user to reopen the app to re-establish a channel connection using the push infrastructure.
The standard way to try and ensure that the channel is always available is to check the channel whenever the app is started.
This is what you're doing, you probably just want to make sure you're updating server records not just adding more.