最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

iOS點(diǎn)擊推送消息跳轉(zhuǎn)處理

 更新時(shí)間:2016年04月12日 14:16:58   作者:jgCho  
這篇文章主要介紹了iOS點(diǎn)擊推送消息跳轉(zhuǎn)處理 的相關(guān)資料,需要的朋友可以參考下

當(dāng)用戶通過(guò)點(diǎn)擊通知消息進(jìn)入應(yīng)用時(shí)

- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions

launchOptions

中會(huì)有推送消息的userInfo信息,此時(shí)我們可以通過(guò)

NSDictionary* remoteNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; 

獲得推送消息內(nèi)容。如果remoteNotification不為空,則說(shuō)明用戶通過(guò)推送消息進(jìn)入,那么可以聲明一個(gè)屬性

@property (nonatomic) BOOL isLaunchedByNotification; 

用于標(biāo)識(shí)用戶是否通過(guò)點(diǎn)擊通知消息進(jìn)入本應(yīng)用。此時(shí),

- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo 

一定會(huì)被調(diào)用,iOS7可以使用

- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler 

因?yàn)榇朔椒ǖ恼{(diào)用時(shí),MainViewController已經(jīng)被初始化,所以我們已經(jīng)可以在MainViewController注冊(cè)推送消息的監(jiān)聽(tīng),用于展示對(duì)應(yīng)的視圖,如下:

//訂閱展示視圖消息,將直接打開某個(gè)分支視圖
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(presentView:) name:@"PresentView" object:nil];//彈出消息框提示用戶有訂閱通知消息。主要用于用戶在使用應(yīng)用時(shí),彈出提示框
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showNotification:) name:@"Notification" object:nil]; 

所以在AppDelegate的didReceiveRemoteNotification中可以通過(guò)判斷isLaunchedByNotification來(lái)通知不同的展示方法。

腦補(bǔ)一個(gè)推送來(lái)臨時(shí),播放震動(dòng)聲音不停止的代碼(不是播放音樂(lè)哦)

首先包含頭文件

#import <AudioToolbox/AudioToolbox.h> 

注冊(cè)一段聲音(本例中直接使用默認(rèn)1007)

@property (nonatomic, assign) SystemSoundID soundID;
NSString *path = [[NSBundle mainBundle] pathForResource:soundName ofType:nil];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:path], &_soundID);
AudioServicesAddSystemSoundCompletion(_soundID, NULL, NULL, soundCompleteCallback, NULL); // 核心代碼 可重復(fù)執(zhí)行
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
AudioServicesPlaySystemSound(_soundID);
// block 用于 AudioServicesAddSystemSoundCompletion(_soundID, NULL, NULL, soundCompleteCallback, NULL); 函數(shù)調(diào)用
void soundCompleteCallback(SystemSoundID soundID,void * clientData)
{
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
AudioServicesPlaySystemSound(soundID);
}
// 停止播放
-(void)stopAlertSoundWithSoundID:(SystemSoundID)soundID 
{
AudioServicesDisposeSystemSoundID(kSystemSoundID_Vibrate);
AudioServicesDisposeSystemSoundID(soundID);
AudioServicesRemoveSystemSoundCompletion(soundID);
}

以上內(nèi)容是小編給大家介紹的iOS點(diǎn)擊推送消息跳轉(zhuǎn)處理的相關(guān)內(nèi)容,希望對(duì)大家有所幫助!

相關(guān)文章

最新評(píng)論

宜都市| 柏乡县| 朝阳县| 徐水县| 泰和县| 康定县| 扎囊县| 积石山| 正定县| 彩票| 平阳县| 永仁县| 武威市| 浑源县| 卓尼县| 泸水县| 旬阳县| 锦屏县| 新兴县| 抚顺市| 股票| 公安县| 喀喇沁旗| 武清区| 巴塘县| 沂南县| 额尔古纳市| 罗平县| 丰城市| 南华县| 湖北省| 德令哈市| 竹溪县| 工布江达县| 县级市| 运城市| 琼海市| 玉龙| 木兰县| 定安县| 四川省|