因爲本身的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大廠面試題