Skip to content
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

Allow updating of tokens #12

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions ios/RCTTwilio/RCTTwilio.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,20 @@ @implementation RCTTwilio {
}

RCT_EXPORT_METHOD(initWithToken:(NSString *) token) {
_phone = [[TCDevice alloc] initWithCapabilityToken:token delegate:self];
if (_phone == nil) {
_phone = [[TCDevice alloc] initWithCapabilityToken:token delegate:self];
} else {
[_phone updateCapabilityToken:token];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be it's own exported method?
Then you can call either init or update from the JS, otherwise this method is a bit of hidden magic for updating the token.
@ream88 How are you using this method in your code? Are you calling initWithToken more than once?

[self.bridge.eventDispatcher sendAppEventWithName:@"deviceDidStartListening" body:nil];
}
}

RCT_EXPORT_METHOD(connect:(NSDictionary *) params) {
_connection = [_phone connect:params delegate:self];
}

RCT_EXPORT_METHOD(disconnect) {
[_connection disconnect];
[_phone disconnectAll];
}

RCT_EXPORT_METHOD(accept) {
Expand Down