由于自己的app想要一個(gè)推送功能,又由于調(diào)用系統(tǒng)的方法集成太麻煩,所以想找一個(gè)推送的SDK來(lái)做。市面上可以實(shí)現(xiàn)該功能的SDK有多種,比如極光,信鴿,個(gè)推,MobPush(ShareSDK他們家的)。于是下面來(lái)對(duì)比一下:
經(jīng)過(guò)對(duì)比得知,在集成上,MobPush更加簡(jiǎn)單,也是他們對(duì)一貫傳統(tǒng),像在ShareSDK上也是比其他SDK要簡(jiǎn)潔很多。看他們對(duì)文檔上這樣的。
首先在info.plist里添加2個(gè)字段:MOBAppKey和MOBAppSecret,對(duì)應(yīng)在mob申請(qǐng)的key。(不用寫(xiě)初始化方法了)
然后直接復(fù)制下面的這句代碼就完成了!!
在- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions中進(jìn)行推送配置
引入頭文件:
#import <span style="font-family: 'Times New Roman'; font-size: 10.5pt; line-height: 1.8em;"><MobPush/MobPush.h></span>
調(diào)用方法:
MPushNotificationConfiguration *configuration = [[MPushNotificationConfiguration alloc] init];configuration.types = MPushAuthorizationOptionsBadge | MPushAuthorizationOptionsSound | MPushAuthorizationOptionsAlert;[MobPush setupNotification:configuration];
appdelegate里的到這里已經(jīng)結(jié)束了。
如果需要獲取到消息的內(nèi)容,監(jiān)聽(tīng)@“MobPushDidReceiveMessageNotification”通知既可。
調(diào)用
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMessage:) name:MobPushDidReceiveMessageNotification object:nil];
接收監(jiān)聽(tīng)
- (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也是占有比較小的,因?yàn)橐灿昧怂鼈兊腟hareSDK,所以它們的公共庫(kù)也可以公用了。
在價(jià)格上,極光和個(gè)推,都是有免費(fèi)版,有VIP服務(wù),我不是VIP也就享受不到了。mobpush是完全免費(fèi),信鴿沒(méi)找到收費(fèi)點(diǎn),應(yīng)該也是免費(fèi)的,而且mob和信鴿都有技術(shù)支持,mob更是號(hào)稱有24小時(shí)1對(duì)1技術(shù)支持。(當(dāng)然我才不信誰(shuí)24小時(shí)了,不過(guò)說(shuō)明他們對(duì)服務(wù)挺看重的)對(duì)于我這種不是太厲害的開(kāi)發(fā)者來(lái)說(shuō)簡(jiǎn)直就是福音啊。
在支持的平臺(tái)上,無(wú)疑極光是支持的最多的,有需要的當(dāng)然選這個(gè)比較好。
綜上,對(duì)于我這個(gè)只需要iOS的app來(lái)說(shuō),當(dāng)然是選一個(gè)輕量級(jí)的,集成簡(jiǎn)單的,服務(wù)好的。最終我選擇了MobPush。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注