Closed victor-padovam closed 1 year ago
@cybex-dev any solution for me help ?
You must log the time you obtained the token and do the calculation to know if it has expired.
For the example you mention, you can use the same funciton you used at startup to get your token from the backend and register it.
As I pass my new changed token to this function, I find I can't pass it as a parameter. how does it work and how does it expect
As I pass my new changed token to this function, I find I can't pass it as a parameter. how does it work and how does it expect
See this from the example provided.
https://github.com/diegogarciar/twilio_voice/blob/master/example/lib/main.dart#L42
@VictorPadovan1997 did the documentation & example provide a solution?
@cybex-dev you can forward me your e-mail to ask a question
@VictorPadovan1997 please ask here as it may help others
@VictorPadovan1997 did the documentation & example provide a solution? @cybex-dev now that I've updated to the updates it got in the package. I'm managing to pass my token as a parameter, but it never enters the print() function and register().
if (updateToken != currentToken) {
TwilioVoice.instance.setOnDeviceTokenChanged((updateToken) {
print("voip-device token changed");
print("token Update is : $updateToken");
register(userId);
});
}
so passing only as a parameter and not print them like this:
TwilioVoice.instance.setOnDeviceTokenChanged((updateToken));
returns this:
_TypeError (type 'String' is not a subtype of type '(String) => dynamic')
@VictorPadovan1997 did the documentation & example provide a solution? @cybex-dev now that I've updated to the updates it got in the package. I'm managing to pass my token as a parameter, but it never enters the print() function and register().
if (updateToken != currentToken) { TwilioVoice.instance.setOnDeviceTokenChanged((updateToken) { print("voip-device token changed"); print("token Update is : $updateToken"); register(userId); }); }
so passing only as a parameter and not print them like this:
TwilioVoice.instance.setOnDeviceTokenChanged((updateToken));
returns this:
_TypeError (type 'String' is not a subtype of type '(String) => dynamic')
The reason is setOnDeviceTokenChanged
requires a function pointer or consumer named OnDeviceTokenChanged
See implementation [here](https://github.com/diegogarciar/twilio_voice/blob/master/lib/twilio_voice.dart#L38)
OnDeviceTokenChanged? deviceTokenChanged;
void setOnDeviceTokenChanged(OnDeviceTokenChanged deviceTokenChanged) {
deviceTokenChanged = deviceTokenChanged;
}
where the function OnDeviceTokenChanged
is defined as
typedef OnDeviceTokenChanged = Function(String token);
i.e. a void function that requires a single String parameter (a consumer).
For your example, you need to do something like
OnDeviceTokenChanged updateToken = (String token) {
print("Token changed to ${token}");
};
TwilioVoice.instance.setOnDeviceTokenChanged(updateToken);
@cybex-dev I just couldn't understand here how I pass my Changed token inside this function you passed.
this is my function and the updated token is coming as a parameter in registerAndUpdateToken. Where I specify the tokenChanged within this method OnDeviceTokenChanged ?
registerAndUpdateToken(String tokenChanged) {
OnDeviceTokenChanged updateToken = (String token) {
print(token);
};
TwilioVoice.instance.setOnDeviceTokenChanged(updateToken);
}
)
@VictorPadovan1997 I'm certain you've resolved this issue by now, however I'll be answering it for the record.
The onDeviceTokenChanged
only applies to the iOS implementation (see SwiftTwilioVoicePlugin.swift#L349 and SwiftTwilioVoicePlugin.swift#L578 as reference).
This onDeviceTokenChanged
event is triggered when the iOS device receives a new Push Token from the APNS which is then used by Twilio to register for push notifications.
Good morning,
I would like to know if the package offers any function when pressing the call button. check if the accessToken is expired?
in the function below how do I pass my new changed token? I tried to pass it as a parameter but it doesn't accept.