2010-01-26 76 views

回答

2

在推送通知,您就可以將被轉移到你的應用程序上打開一個「有效載荷」:

您的應用程序將獲得「用戶信息」(NSDictionary中)作爲參數去didFinishLaunchingWithOptions()方法。

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo 
Parameters 
application 
The application interested in the remote notification. 
userInfo 
A dictionary that contains information related to the remote notification, potentially including a badge number for the application icon, an alert sound, an alert message to display to the user, a notification identifier, and custom data. The provider originates it as a JSON-defined dictionary that iPhone OS converts to anNSDictionary object; the dictionary may contain only property-list objects plus NSNull. 

要設置有效負載,請參閱Apple Push Notification Service Programming Guide。基本上,您可以在那裏發送任何類型的信息,以幫助應用程序將用戶路由到內部的正確位置。

+1

請記住,只有當用戶在收到「推送」通知時允許該應用程序打開時纔會這樣。如果用戶不允許打開該應用程序,則在應用程序的後續打開時,該信息將不會被應用程序接收。應用程序將不得不向發送服務器查詢應該在關閉時收到的更新。 – Jann 2010-03-20 07:35:21