admin管理员组文章数量:1565789
1第一步:http://www.mob/#/downloadDetail/SMS/ios 进入这个网址下载最新版SDK,解压后得到文件
2第二步、导入SDK
第三步、添加依赖库文件
-
必要:
-
- libz.dylib
- libicucore.dylib
- MessageUI.framework
- JavaScriptCore.framework
- libstdc++.dylib
-
可选:
-
- AddressBook.framework (通讯录功能需要)
- AddressBookUI.framework(通讯录功能需要)
第四步、添加初始化代码
1、在appDelegate 添加
1 | #import <SMS_SDK/SMSSDK.h> |
2 、在
1 | - ( BOOL ) application : ( UIApplication * ) application didFinishLaunchingWithOptions : ( NSDictionary * ) launchOptions |
添加
1 2 3 | //初始化应用,appKey和appSecret从后台申请得 [ SMSSDK registerApp :appKey withSecret :appSecret ] ; |
appKey 和 appSecret的获取:
(1)到Mob官网(http://www.mob/#/)注册成为Mob开发者;
(2)到应用管理后台(http://dashboard.mob/#/main/index)新建应用。新建应用步骤,请参考:网址(http://bbs.mob/forum.php?mod=viewthread&tid=8212&extra=page%3D1)
第五步、使用SDK提供的API
SMSSDK.h文件为SMSSDK的核心类。这个类的所有方法以类方法提供,根据需要直接使用相应的方法。
短信UI部分是以Demo形式开源的,具体参考Demo。以下是Demo中部分UI模块的说明:
1、弹出注册页面
1 2 3 4 | RegViewController * reg = [ [ RegViewController alloc ] init ] ; [ self presentViewController :reg animated :YES completion : ^ { } ] ; |
注册界面RegViewController,进入该界面后,可选择国家和地区和输入手机号码进行短信注册验证;
选择国家和地区的选项进入SectionsViewController,在该控制器会从服务端获取所支持的国家和地区;
用户在注册页面输入手机号码之后,点击下一步,界面跳转到短信验证界面同时服务端会发送短信验证码到手机;
短信验证界面对应的控制器为VerifyViewController 主要处理短信的验证功能。
2、弹出通讯录好友界面
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | [ _testView setNumber : 0 ] ; SectionsViewControllerFriends * friends = [ [ SectionsViewControllerFriends alloc ] init ] ; _friendsController = friends ; [ _friendsController setMyBlock : _friendsBlock ] ; [ SMS_MBProgressHUD showMessag :NSLocalizedString ( @"loading" , nil ) toView :self . view ] ; [ SMSSDK getAllContactFriends : 1 result : ^ ( NSError *error , NSArray *friendsArray ) { if ( ! error ) { [ _friendsController setMyData : [ NSMutableArray arrayWithArray :friendsArray ] ] ; [ self presentViewController : _friendsController animated :YES completion : ^ { ; } ] ; } } ] ; //判断用户通讯录是否授权 if ( _alert1 ) { [ _alert1 show ] ; } if ( ABAddressBookGetAuthorizationStatus ( ) != kABAuthorizationStatusAuthorized && _alert1 == nil ) { NSString * str = [ NSString stringWithFormat :NSLocalizedString ( @"authorizedcontact" , nil ) ] ; UIAlertView * alert = [ [ UIAlertView alloc ] initWithTitle :NSLocalizedString ( @"notice" , nil ) message :str delegate :self cancelButtonTitle :NSLocalizedString ( @"sure" , nil ) otherButtonTitles :nil , nil ] ; _alert1 = alert ; [ alert show ] ; } |
通讯录好友界面SectionsViewControllerFriends,在事件响应中弹出该好友控制器即可;进入该界面后 会把通讯录的好友分为两类:
- 已加入的用户:可以点击添加按钮,直接添加已加入该app的通讯录好友。
- 待邀请的用户:可以点击邀请按钮发送短信邀请好友加入该app。
-(void)getVerifyCode{
[SMSSDK getVerificationCodeByMethod:SMSGetCodeMethodSMS phoneNumber://此处填写自己的手机号码 zone:@"86" customIdentifier:nil result:^(NSError *error) {
NSLog(@"-----%@",[self.textFliedArrM[3] text]);
dispatch_async(dispatch_get_main_queue(), ^{
if (!error) {
UIAlertView *alertV=[[UIAlertView alloc]initWithTitle:@"提示信息" message:@"验证码已发送,请注意查收" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alertV show];
}else{
UIAlertView *alertV=[[UIAlertView alloc]initWithTitle:@"提示信息" message:@"验证码发送失败" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alertV show];
}
});
}];
}
版权声明:本文标题:iOS开发中短信提醒功能详解步骤 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/xitong/1727266435a1105570.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论