0

So I got my first push notifications from my PHP server to the iPhone working (so excited!)

Now when the user clicks on the notification, my app reloads, but it reloads to whatever point it left off at obviously.

Is there a way I can have the app know that it was reloaded from a iOS notification click?

And the next step is to read a custom variable that I sent along with the notification, how would I read my variable? (I added the custom variable to my payload as follows:)

$payload['aps'] = array('alert' => 'This is the alert text', 'badge' => 1, 'sound' => 'default', 'customVar' ==> '1');
4

1 回答 1

1

马克,您可以使用Register For Push Notifications 方法回调属性获取自定义属性。由于在此回调方法中编写的任何代码都将在接收到远程推送时被调用。

Titanium.Network.registerForPushNotifications({
    types: [
        Titanium.Network.NOTIFICATION_TYPE_BADGE,
        Titanium.Network.NOTIFICATION_TYPE_ALERT,
        Titanium.Network.NOTIFICATION_TYPE_SOUND
    ],
  success:function(e)
  {
      deviceToken = e.deviceToken;
      alert("deviceToken = "+deviceToken);
      registerForPush();
  },
  error:function(e)
  {
      alert("Error: "+e.message);
  },
  callback:function(e)
  {
      //It'll be invoked on receiving a remote push, this e.data will contain your custom variables also
      alert("push notification received"+JSON.stringify(e.data));
  }
});

您可以使用此链接了解更多信息。

于 2013-06-03T04:58:56.330 回答