因为本身的app想要一个推送功能,又因为调用系统的方法集成太麻烦,因此想找一个推送的SDK来作。市面上能够实现该功能的SDK有多种,好比极光,信鸽,个推,MobPush(ShareSDK他们家的)。因而下面来对比一下:面试
screenshot.pngbash
在集成上,MobPush更加简单,也是他们对一向传统,像在ShareSDK上也是比其余SDK要简洁不少。看他们对文档上这样的。app
首先在info.plist里添加2个字段:MOBAppKey和MOBAppSecret,对应在mob申请的key。(不用写初始化方法了)ui
mob1
而后直接复制下面的这句代码就完成了!!
在- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions中进行推送配置
引入头文件:
#import <MobPush/MobPush.h>
调用方法:
MPushNotificationConfiguration *configuration = [[MPushNotificationConfiguration alloc] init];
configuration.types = MPushAuthorizationOptionsBadge | MPushAuthorizationOptionsSound | MPushAuthorizationOptionsAlert;
[MobPush setupNotification:configuration];
复制代码
appdelegate里的到这里已经结束了。spa
若是须要获取到消息的内容,监听@“MobPushDidReceiveMessageNotification”通知既可。code
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMessage:) name:MobPushDidReceiveMessageNotification object:nil];
接收监听
- (void)didReceiveMessage:(NSNotification* )notification
{
MPushMessage *message = notification.object;
switch (message.messageType)
{
case MPushMessageTypeNotification:
{
[MobPush addLocalNotification:message];
}
break;
case MPushMessageTypeCustom:
{
NSLog(@"Message:%@",message.content);
}
break;
default:
break;
}
}
复制代码
在sdk大小上,MobPush也是占有比较小的,由于也用了它们的ShareSDK,因此它们的公共库也能够公用了。server
在价格上,极光和个推,都是有免费版,有VIP服务,我不是VIP也就享受不到了。mobpush是彻底免费,信鸽没找到收费点,应该也是免费的,并且mob和信鸽都有技术支持,mob更是号称有24小时1对1技术支持。(固然我才不信谁24小时了,不过说明他们对服务挺看重的)对于我这种不是太厉害的开发者来讲简直就是福音啊。开发
在支持的平台上,无疑极光是支持的最多的,有须要的固然选这个比较好。文档
推荐文章get
点击进群交流密码:111 进群领取2020大厂面试题