To run the example project, clone the repo, and run pod install
from the Example directory first.
DPGodChat is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'DPGodChat'
[email protected], [email protected]
#import <ChatFramework/GCChatViewController.h>
#import <ChatFramework/GodChatSDK.h>
[[GCSessionManager shareSessionManager] presentGodCallViewControllerWithUsername:@"" password:@"" animated:YES];
#import <ChatFramework/GodChatSDK.h>
注册js监听事件
WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
[config.userContentController addScriptMessageHandler:self name:@"videoChat"];
/** 通过网页返回的方法名调用我们写的方法 */
- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message {
if ([message.name isEqualToString:@"videoChat"]) {
[self videoChat:message.body];
}
}
- (void)videoChat:(NSDictionary *)params {
NSLog(@"videoChat");
[[GCSessionManager shareSessionManager] presentGodCallViewControllerWithUsername:params[@"username"] token:params[@"token"] animated:YES];
[[GCSessionManager shareSessionManager] presentGodCallViewControllerWithAnimated:YES];
}
- (void)dealloc
{
if (_wkWebView)
{
[_wkWebView.configuration.userContentController removeScriptMessageHandlerForName:@"videoChat"];
}
}
DPGodChat is available under the MIT license. See the LICENSE file for more info.