Return more details about notification registration failure
This commit is contained in:
@@ -311,14 +311,15 @@ class CapacitorNotifications implements IPushAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let {token} = notificationState.get()
|
let {token} = notificationState.get()
|
||||||
|
let error = "failed to retrieve token"
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
const listeners = [
|
const listeners = [
|
||||||
PushNotifications.addListener("registration", ({value}: Token) => {
|
PushNotifications.addListener("registration", ({value}: Token) => {
|
||||||
token = value
|
token = value
|
||||||
}),
|
}),
|
||||||
PushNotifications.addListener("registrationError", (error: RegistrationError) => {
|
PushNotifications.addListener("registrationError", (err: RegistrationError) => {
|
||||||
console.error(error)
|
error = err.error
|
||||||
}),
|
}),
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -334,7 +335,7 @@ class CapacitorNotifications implements IPushAdapter {
|
|||||||
notificationState.update(assoc("token", token))
|
notificationState.update(assoc("token", token))
|
||||||
}
|
}
|
||||||
|
|
||||||
return token ? "granted" : "denied"
|
return token ? status.receive : error
|
||||||
}
|
}
|
||||||
|
|
||||||
async _syncServer(signal: AbortSignal) {
|
async _syncServer(signal: AbortSignal) {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
return pushToast({
|
return pushToast({
|
||||||
theme: "error",
|
theme: "error",
|
||||||
message: "Failed to request notification permissions.",
|
message: `Failed to request notification permissions (${permissions}).`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user