[問題] pushnotification 的問題
如果我initial view controller 為A
A會push出B or C
B也會push出D
C也會push出E
當我接收到RemoteNotification時
不論當下任何的view controller
我都要push出一個特定的頁面
目前我的做法是
在AppDelegate中
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo {
[PFPush handlePush:userInfo];
NSLog(@"%@",userInfo);
[[NSNotificationCenter defaultCenter] postNotificationName:@"test"
object:nil userInfo:nil];
}
然後每個viewcontroller加上
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleCurrentViewController:) name:@"test" object:nil];
}
- (void)handleCurrentViewController:(NSNotification *)notification {
PushNotificationViewController* pvc = [self.storyboard
instantiateViewControllerWithIdentifier:@"PushNotification"];
[self presentViewController:pvc animated:YES completion:nil];
}
但是如果我現在在B頁面
因為B是由Apush出來的
所以我A跟B都會接收到NSNotificationCenter的訊息
都會觸發
請問如何修改會比較好
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 60.248.186.235
※ 文章網址: http://www.ptt.cc/bbs/MacDev/M.1415003180.A.45D.html
→
11/03 16:29, , 1F
11/03 16:29, 1F
→
11/03 16:29, , 2F
11/03 16:29, 2F
推
11/04 09:09, , 3F
11/04 09:09, 3F