CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.
License | Commercial |
ReleasedLast Release | Mar 2017 |
SwiftSwift Version | 3.0 |
Maintained by jonathan affriat.
Depends on: | |
Alamofire | ~> 4.3 |
SwiftyJSON | >= 0 |
KeychainAccess | >= 0 |
DateToolsSwift | >= 0 |
SwiftR | >= 0 |
Add TokyWoky SDK to your Podfile and run pod install
target :YourTargetName do
pod 'TokyWokySdk'
end
Get your public API key and your client ID. Import TokyWokySdk and initialize the widget by adding the following to your application delegate :
-Swift-
import TokyWokySdk
var tokyWidget = TokyWidget(apiKey: "<Your iOS API Key>", clientId: <Your client ID>)
-ObjC-
@import TokyWokySdk
TokyWidget *tokyWidget = [[TokyWidget new] initWithApiKey:@"<Your iOS API Key>" clientId:<Your client ID>];
Check if the current user is connected and otherwise log him in using one of the 3 login functions available:
-Swift-
tokyWidget.isAuthenticated() { isLoggedIn in
if (!isLoggedIn) {
//login is possible using tokyLoginVisitor() and tokyLoginSso(ssoString: String)
self.tokyWidget.tokyLogin(email: "<Your user email>", pwd: "Your user password"){
startTokyWoky()}
} else {
startTokyWoky()
}
}
-ObjC-
[tokyWidget isAuthenticatedWithCompletion:^(BOOL isAuthenticated) {
if (!isAuthenticated) {
[tokyWidget tokyLoginVisitorWithCompletion:^() {
[self startTokyWoky];
}];
} else {
[self startTokyWoky];
}
}];
Once you are sure that your user is authenticated, you can get the webview and start using the widget:
-Swift-
func startTokyWoky() {
var tokyWebView = tokyWidget.getTokyWebView()
tokyWebView.translatesAutoresizingMaskIntoConstraints = false
self.view = tokyWebView
}
-ObjC-
-(void)tokyStart {
TokyWebView *tokyWebView = [self.tokyWidget getTokyWebView];
[tokyWebView setTranslatesAutoresizingMaskIntoConstraints:NO];
self.view = tokyWebView;
}
You can enable real-time for the best user experience. Call the function to init real-time and provide a callback for new messages. Make a call to get the number of unread messages:
-Swift-
self.tokyWidget.startSignalR() { message in
self.tokyWidget.getUnreadChats(isSignalR: true) { nbNotifs in
if (nbNotifs > 0) {
// Display notifs badge
}
}
}
-ObjC-
[self.tokyWidget startSignalRWithCompletion:^(NSString* mess) {
[self.tokyWidget getUnreadChatsWithIsSignalR:false completion:^(NSInteger nbNotifs) {
// Display notifs badge
}];
}];
Make sure your user is still authenticated when your app become active again by calling the following in your application delegate:
-Swift-
func applicationWillEnterForeground(_ application: UIApplication) {
tokyWidget.enterForeground()
}
-ObjC-
- (void)applicationWillEnterForeground:(UIApplication *)application {
[self.tokyWidget enterForeground];
}
You can log out an user and delete his authentication's tokens by calling:
-Swift-
tokyWidget.tokyLogout()
-ObjC-
[self.tokyWidget tokyLogout];