Tuesday, 15 February 2011

ios - Launching a specific viewController in response to a remote push notification -



ios - Launching a specific viewController in response to a remote push notification -

i'm creating app who's storyboard flows image below:

when user logs in "sysalert view controller" brought "message list view controller" nsurlconnection load json table. when user taps row in table, brought "message details" shows more detailed info message.

when user launches app force notification, regardless of state of app prior launching, want app load "message list" info server , show them message that's been pushed device.

i know need utilize didfinishlaunchingwithoptions tell app react force notification how setup view hierarchy "message list" view controller loads info , pushes "message details" view controller onto stack appropriate message?

essentially kind of mimics behaviour of messages or mail service apps. opening notification brings view controller message still able move in hierarchy if had launched app initial viewcontroller , traversed through viewcontrollers in turn.

it's possible describe, not recommend it.

frist, place disconnected view controller view want in storyboard, give view controller identifier, "my force notification view"

in didfinishlaunchingwithoptions:, can rootviewcontroller app delegate. controller navigation controller. using navigation controller, can force new view controller on top of stack. create new view controller, instantiate view controller identifier "my force notification view".

uinavigationcontroller *navcontroller = (uinavigationcontroller *)self.window.rootviewcontroller; uiviewcontroller *notificationcontroller = [navcontroller.storyboard instantiateviewcontrollerwithidentifier:@"my force notification view"]; [navcontroller pushviewcontroller:notificationcontroller animated:yes];

i think want utilize -presentviewcontroller:animated:completion: show modal view instead of interrupting navigation stack.

uiviewcontroller *rootcontroller = (uiviewcontroller *)self.window.rootviewcontroller; uiviewcontroller *notificationcontroller = [rootcontroller.storyboard instantiateviewcontrollerwithidentifier:@"my force notification view"]; [rootcontroller presentviewcontroller:notificationcontroller animated:yes completion:null];

ios uiviewcontroller push-notification apple-push-notifications

No comments:

Post a Comment