14
12

More than 5 years have passed since last update.

AIR for iOS Pushまわりの挙動まとめ

Posted at

AIR3.4からiOSのプッシュをサポートしてる

ドキュメント: Adobe AIR * プッシュ通知の使用

挙動を覚えてられないのでまとめておく

ものすごく雑にまとめると

Pushからの起動だと

NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, onInvoke)

event.argumentsから取得可能。

起動中だと

_notifier = new RemoteNotifier();
_notifier.addEventListener(RemoteNotificationEvent.NOTIFICATION, onNotification);

event.data から取得可能。

入ってるデータ

こんな感じで入っている。Invokeでも、RemoteNotificationも同じ。

{
  "aps" : "{\n    alert = \"\hogehoge";\n}",
  "data" : "hogehoge"
}

起動していない状態でPushを受け取った場合

  • RemoteNotificationEvent.NOTIFICATION
    • 飛んでこない
  • Invoke
    • あり
    • invokeEvent.argumentsの中に入っている。
    • この状態から、suspendにまわして、再度全面に持ってきたときのinvokeイベントにはargumentsが空っぽ = 期待通りの挙動

アプリが起動中の場合

  • RemoteNotificationEvent.NOTIFICATION
    • 飛んでくる。event.dataに入っている
  • Invoke: なし

suspend状態の場合

起動中の場合と似ている。違いはinvokeイベント後にNOTIFICATIONイベントが飛んでくる

  • RemoteNotificationEvent.NOTIFICATION
    • invokeイベント後に飛んでくる。event.dataに入っている
  • Invoke: なし

LocalNotificationの挙動も別途まとめます

まとめるよ!

14
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
12