-
-
Notifications
You must be signed in to change notification settings - Fork 874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Installation deviceToken is undefined #1224
Comments
It should not. Can you provide more details regarding the circumstances and number of times you have seen this happen? |
I see other users in the dashboard which have subscribed to push notifications and do not have a device token either so it's not just happening on my device. Deleting the app and reinstalling will cause the app to create a new Installation with a defined deviceToken but after around 1-2 weeks the deviceToken is back to nil. I thought maybe the deviceToken coming back from didRegisterForRemoteNotifications was nil so I first check if the deviceToken has data before setting it to the Installation
The docs recommend registering for remote notifications when applicationDidFinishLaunching is called however since I don't want the notification prompt to come up on first launch I am only registering notifications when the user begins subscribing to channels. |
So in your this only happening for iOS related devices? By chance do you also have any android installs as well that are not doing this? If so that helps narrow it down to something more specifically regarding just this sdk. It should be noted that the server-side requirement is either a deviceToken or an installationId. If you need to guard against strange behavior with null deviceTokens you can always setup a beforeSave hook to provide a check to require a deviceToken. Parse.Cloud.beforeSave('_Installation', function(request, response) {
if(!request.object.get('deviceToken')) {
// prevent from saving
// note the bad installation
// maybe do something else to help track it with details...
response.error('installation blocked from being saved! Device token missing!');
} else {
response.success();
}
}); |
Any chance you're using the configuration parameter PARSE_SERVER_CLEANUP_INVALID_INSTALLATIONS when you start your parse server ? |
@brianyyz am running parse server on Heroku and have PARSE_SERVER_CLEANUP_INVALID_INSTALLATIONS set to 1 in config vars. |
@montymxb I don't have push enabled for Android (yet) so would have no way of knowing if it's just an iOS issue. I'll try adding the beforeSave logic and see if that fixes the issue. Thanks! |
So if you have that feature flag enabled, this is actually the expected behavior. Remove the feature flag if you don’t want to cleanup the invalid device tokens. |
@flovilmart According to this post you said this should be the default behavior so won't I experience the same issue even without the flag? |
It’s still feature flagged, as of today, so removing the flag would be ok if you don’t need the feature |
How does parse-server decide a token is invalid? If I remove this feature then won't my installation be filled with invalid device tokens? |
The server removed the invalid tokens based on the response from the push adapter. APNS or GCM return explicit responses when trying to send a push to a token that is no longer valid. Depending on your use cases, you may wanna keep the feature or not. this is where the decision is made: https://github.com/parse-community/parse-server/blob/c1a734714361ba65e32c9781d3c8f924f1187df5/src/StatusHandler.js#L230 |
I will try without this feature. Thanks. |
I can confirm that setting PARSE_SERVER_CLEANUP_INVALID_INSTALLATIONS to 1 actually clears VALID deviceTokens for iOS users. Setting this parameter is actually dangerous for your service! 30% of our iOS users lost the ability to receive push notifications after we set the variable to 1. |
@halvini, I’m curious why it would clean those valid tokens when APNS returns clearly an error for the particular token |
@flovilmart, I'm curious too. @adammlevy said: "Deleting the app and reinstalling will cause the app to create a new Installation with a defined deviceToken but after around 1-2 weeks the deviceToken is back to nil." We had exactly the same issue with the users who had valid deviceTokens. When we switched the PARSE_SERVER_CLEANUP_INVALID_INSTALLATIONS to 1, iOS users started massively reporting that they don't get any Push Notifications. Android users didn't experience such problems though. |
@flovilmart any ideas how to resolve this issue? |
I have noticed that after a period of time receiving push notifications on my device I will suddenly stop receiving push notifications on that device. One thing I have noticed is that the deviceToken is set to (undefined) in the dashboard as seen in the included screenshot. How is it possible that the deviceToken goes from some value to undefined.
The text was updated successfully, but these errors were encountered: