Invalid Tokens #116
Unanswered
tierracero
asked this question in
Q&A
Replies: 2 comments 3 replies
-
I will be also interested in getting this feature from the API |
Beta Was this translation helpful? Give feedback.
3 replies
-
Found this thread while I was trying to figure this out, here's the solution I came up with using the let tokens = // Fetch your list of tokens here...
guard !tokens.isEmpty else {
request.logger.error("No tokens registered!")
return
}
tokens.forEach { token in
request.apns.send(notification, to: token).whenFailure { error in
guard let error = error as? APNSwiftError.ResponseError else {
request.logger.report(error: error)
return
}
switch error {
case .badRequest(let apnsResponseError):
if apnsResponseError == .unregistered {
request.logger.error("Deleting unregistered token: \(token)")
// Delete your unregistered token here...
} else {
request.logger.error("Error \(apnsResponseError) for \(token)")
}
}
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi is their a way to get an error when a token is no longer valid ?? ive been trying to find some solution but can't find anything in the docs or code that could help me that :D
Beta Was this translation helpful? Give feedback.
All reactions