objective c - ios push notifications to a specific view controller -
my app receives remote push notifications , upon receiving them, take specific view controller(pretty time). have seen code (on didreceiveremotenotification). using storyboard apps.
uiviewcontroller *vc = self.window.rootviewcontroller; pushviewcontroller *pvc = [vc.storyboard instantiateviewcontrollerwithidentifier:@"someid"]; [vc presentviewcontroller:pvc animated:yes completion:nil];
this seems straightforward enough. have impact on memory allocation, looks every time push notification arrives, instantiating new view controller. best practice?
you can try like:
pushviewcontroller *vc = [self.storyboard instantiateviewcontrollerwithidentifier:@"someid"]; [[uiapplication sharedapplication].keywindow.rootviewcontroller presentviewcontroller:vc animated:yes completion:nil];
you dont need allocate uiviewcontroller rootview everytime unless want have uiviewcontroller present pushvc.
if doing in app delegate, storyboard reference by:
uistoryboard *test=[uistoryboard storyboardwithname:@"name" bundle:nil];
and call
[test instantiateviewcontrollerwithidentifier.....
Comments
Post a Comment