I am following Twilio firebase quickstart until point 7, which actually includes the final push notification test, but i am a bit confused on the binding between "identity" and "address". In my understanding the address is just the previously received token so I tried to just register them (didn't use register before to be honest)
messaging.getToken()
.then(function(currentToken) {
if (currentToken) {
console.log('Token received: ', currentToken)
const identity = 'myidentity'
const address = currentToken
register(identity, address)
}
})
Unfortunately register expects type "Hooks" and not a string (message is "Argument of type 'string' is not assignable to parameter of type 'Hooks | undefined'.Vetur(2345)")
What am I missing?
Twilio developer evangelist here.
The register function is actually defined in the notify_actions.js file that is part of the example repo. It looks like:
function register(identity, address){
var url = "http://127.0.0.1:3000/register";
data = {
'identity': identity,
'address': address,
'binding_type': 'fcm'
}
postRequest(url, data);
}
And postRequest is a wrapper around XMLHttpRequest to make the request to your server. This is intended to send the identity and address/token first to your server and then on to the Twilio Notify API to register the identity with the device token. You can see this in the SDK starter back-end that the Notify quickstart uses to create the binding.
I'm not sure where your register function comes from or why it is giving an error to do with "Hooks", but this is what it should be doing. Hopefully that can help.