M800SDK使用手册:.docx_第1页
M800SDK使用手册:.docx_第2页
M800SDK使用手册:.docx_第3页
M800SDK使用手册:.docx_第4页
M800SDK使用手册:.docx_第5页
已阅读5页,还剩9页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

M800SDK使用手册:1.导入M800SDK2. Add path to project Library Search Path添加SDK路径3. Add libraries to project libc+.dylib libresolv.dylib libstdc+.6.0.9.dylib libxml2.dylib libz.dylib libm800sdk-2.2.0.a 4.配置info.plist. 1 M800DeveloperKey : your developer key (supplied by M800) . 2 M800ApplicationKey : your application key (supplied by M800) . 3 M800ApplicationIdentifier : your application identifier (supplied by M800) . 4 M800ApplicationVersion : 1.0.0 (default value) . 5 M800Capabilities : incoming, outgoing (default value) . 6 M800Expiration : 36000 (in second) . 7 M800CarrierName : your carrier name (supplied by M800) . 设置应用信息提供商:. +(void)setApplicationInformationProvider:(id)provider;设置数字签名:. +(void)setCapabilitiesSignatureProvider:(id)provider;生产数字签名的例子: /Generating Signature+ (NSString*)genCapSigWithCapabilities:(NSString*)cap expires:(NSString*)expiresapplicationSecret:(NSString*)applicationSecret NSString * content = NSString stringWithFormat:%, cap, expires; const char *cKey = applicationSecret cStringUsingEncoding:NSUTF8StringEncoding; const char *cData = content cStringUsingEncoding:NSUTF8StringEncoding; unsigned char cHMACCC_SHA256_DIGEST_LENGTH; CCHmac(kCCHmacAlgSHA256, cKey, strlen(cKey), cData, strlen(cData), cHMAC); NSMutableString *output = NSMutableString stringWithCapacity:CC_SHA256_DIGEST_LENGTH; for (int i=0; iCC_SHA256_DIGEST_LENGTH; i+) output appendFormat:%02x, cHMACi; return NSString stringWithString:output;与我们的M800服务器进行通信,使用的方法在M800SDK+ Management.h您可以使用下面的代码注册:M800SDK sharedInstance signupWithSourceNetworkId:jid displayName:displayNamelanguage:M800LanguageEnglish completeBlock:(BOOL isSuccess, NSError *error) if (isSuccess)/Success else /Error ;服务器返回以下内容 M800SDK sharedInstance bareJid; M800SDK sharedInstance prefixOfJid; M800SDK sharedInstance carrierName; M800SDK sharedInstance username;得到它们。用以下代码和服务器建立链接M800SDK sharedInstance connectWithCompleteBlock:(BOOL isSuccess, NSError *error) if (isSuccess) /TODO do some things after successful connection. else if (M800SDK sharedInstance needKickUserWithError:error) /TODO Must kick current user out of app.else /TODO do something when failed to connect.;检查是否需要踢出用户(是否在新设备登录或者验证失败):M800SDK sharedInstance needKickUserWithError:(NSError* error) /error handling; 验证,添加,移除身份信息:/ Validate a phone number if needsM800SDK sharedInstance validateNumber:12345678 country:hk language:zhvalidType:SMS complete:(NSString *validateCode) _validateCode = validateCode; error:(NSError *error) ;/ Signup a phone number as additional identity with/without verificationM800SDK sharedInstance signupAdditionIdentityWithNumber:12345678 country:hk validateCode:_validateCode smsCode:smsCodeReceived nonVerifiedMode:NO passiveValidation:NO completeBlock:nil;/ Remove an existing additional identityM800SDK sharedInstance removeAdditionIdentityWithNumber:12345678 country:hkcompleteBlock:nil;文本功能在M800SDK+ IM.h中发送内容给JID:M800SDK sharedInstance sendMessage:Content to:JID;消息发送成功回调:- (void) didMessageSend:(NSString*) msgId; 没发送成功(消息发送失败)- (void) didMessageSendingFailed:(NSString*) msgId;客户端收到消息:- (void) didServerReceived:(NSString *) msgId;服务器收到该消息,并返回信息,回调以下方法:- (void)didClientReceived:(NSString *) msgId;创建群聊天室:-(void) createRoom:(NSArray*)jids subject:(NSString*)subject complete:(void()(M800Room*)completeBlock error:(void()(NSError*)errorBlock;聊天室添加人员:-(void) inviteParticipants:(NSArray*) jids toRoom:(M800Room *)room complete:(void ()(M800Room *)completeBlock error:(void()(NSError *)errorBlock;参与者离开聊天室:- (void)leaveRoom:(M800Room *) room complete:(void ()(void)completeBlock error:(void()(NSError *)errorBlock;踢出参与者:- (void)kickParticipant:(NSString*)jid fromRoom:(M800Room *)room complete:(void ()(M800Room*)completeBlock error:(void ()(NSError *)errorBlock;下载群聊的聊天室列表:-(void)queryMembershipAndCreateRoomsWithCompleteBlock:(void ()(BOOL)completeBlockerror:(void()(NSError *)errorBlock;更新聊天室成员:- (void)queryMembershipForSingleRoom:(NSString *) roomId completeBlock:(void ()(BOOL)completeBlockerror:(void ()(NSError *)errorBlock;如果要在列表视图中显示所有的聊天室列表需要获得NSFetchedResultsController-(NSFetchedResultsController*)roomsFetchedResultsController; 使用代理方法处理消息:- (void) incomingMessage:(M800Message *) message inRoom:(M800Room *) room;图片共享:发送图片到聊天室:UIImage * image = UIImage imageNamed:M800.jpg;CLLocationCoordinate2D location;M800Room * room = M800SDKsharedInstance roomWithBareJid:+096578_1234;M800SDK sharedInstance sendImage:imageroom:room tags:nil location:location;你可以发送一个只出现几秒的图片?:- (void)sendEphemeralImage:(UIImage*)imageroom:(M800Room*)roomtags:(NSString*)tagslocation:(CLLocationCoordinate2D)location;语音发送:NSURL * url = NSURLURLWithString:file:/localhost/private/var/mobile/Applications/XXXXX/tmp/record_temp.m4a;CLLocationCoordinate2D location;M800Room* room = M800SDK sharedInstanceroomWithBareJid:+096578_1234;M800SDK sharedInstancesendAudioWithFileURL:url room:room tags:tags location:location;视频信息:NSURL * url = NSURLURLWithString:file:/localhost/private/var/mobile/Applications/XXX/tmp/capture/capturedvideo.MOV;CLLocationCoordinate2D location;M800Room * room = M800SDK sharedInstanceroomWithBareJid:+096578_1234; M800SDK sharedInstancesendVideoWithFileURL:url room:room tags:tags location:location;广播消息:M800SDK+IM_Broadcast.h CLLocationCoordinate2D location;M800SDK sharedInstance sendMessage:text destUsers:user1,user2 tags:nil withGeoLocation:location;位置信息分享:M800SDK+IM.h & M800SDK+IM_Broadcast.h- (void)shareLocation:(CLLocationCoordinate2D)location message:(NSString*)message room:(M800Room*)room tags:(NSString*)tags;添加语音功能:id client = M800ClientAccessor client;client addClientDelegate:delegate;实现以下代理方法- (void)clientReady:(id)client userInfo:(NSDictionary*)userInfo;- (void)clientNotReady:(id)client reason:(NSError*)reasonuserInfo:(NSDictionary*)userInfo;打电话:1. 生成一个唯一的呼叫IDNSString * callID = NSString stringWithFormat:m800demo-onnet-%d, (int)NSDate timeIntervalSinceReferenceDate;. 2.创建一个呼叫会话id client = M800ClientAccessor client; id call = client createCall:+85212345678 display:display name. carrier: userInfo:nil callID:callID enableICE:YES;. . 3.呼叫(拨出电话)call dial; call addCallDelegate:delegate;. . 拨出后处理呼叫事件. -(void)callDial:(id)call;. -(void)callEstablishing:(id)call;- (void)callProgress:(id)call status:(NSNumber *)code; -(void)callBeginTalking:(id)call; . - (void)callTerminated:(id)call status:(NSNumber *)codeuserInfo:(NSDictionary*)info;接收来电:登记远程推送服务,获取设备令牌,令牌设备上传服务器- (void)application:(UIApplication *)applicationdidRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken /This code will upload the deviceToken to the M800 server for sending push callnotifications. M800SDK sharedInstance application:applicationdidRegisterForRemoteNotificationsWithDeviceToken:deviceToken;当接收远程推送通知时,使用下面的代码来捕获- (void)application:(UIApplication *)applicationdidReceiveRemoteNotification:(NSDictionary *)userInfo / Processing call notification id client = M800ClientAccessor client; id call = client catchRemoteNotification:userInfo; if (call) /Open customized answer call screen./Note: Now can add M800CallDelegate to receive call events. call addCallDelegate:delegate;使用调用对象(id )接听或拒绝来电call answer;/ After answer, will receive events from delegate: - (void)callAnswering:(id)call; - (void)callBeginTalking:(id)call; call reject:reason; / After reject, will receive below event from delegate: - (void)callTerminated:(id)call status:(NSNumber *)code userInfo:(NSDictionary*

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论