iPadアプリ内でRemoteNotificationでサーバからPush通知を受けた後に、ダウンロードを行ってCoreData内を最新の状態にする処理を組み込んでおります。
証明書などの手続きを一通り終わらせて、XCodeのデバッグアプリを実行しPush通知を受けた後にダウンロード処理が動くことも確認しました。
この際に、
- フォアグラウンド時 ... OK
- バックグラウンド時 ... OK
それぞれにおいて実行されることを確認しました。
ところが、XCodeによるデバッグではなくiPadからアプリを起動し、一旦Homeボタンを押してバックグラウンドにさせた後にPush通知を送ると反応がありません。これがフォアグラウンドの場合はうまくいきます。
- フォアグラウンド時 ... OK
- バックグラウンド時 ... NG
CapabilitiesのBackground ModesはONです。
Background fetchはON。
RemoteNotificationはON。
InfoのRequired background modesのApp downloads contents from the network設定はあります。
InfoのRequired background modesのApp downloads content in response to push notification設定はあります。
Remote Notificationの登録はwillFinishLaunchingWithOptions内で以下を行っております。
c
1 2flgNotifiType = 3 UIUserNotificationTypeBadge | 4 UIUserNotificationTypeSound | 5 UIUserNotificationTypeAlert; 6objNotifiSetting = [UIUserNotificationSettings settingsForTypes:flgNotifiType 7 categories:nil]; 8[application unregisterForRemoteNotifications]; 9[application registerUserNotificationSettings:objNotifiSetting]; 10[application setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum]; 11
以下のサイトを参考に、
【iOS7】プッシュ通知のバックグラウンド処理でハマったメモ
[application unregisterForRemoteNotifications];
を入れております。
このサイトではiOS7なので若干違っており、UIRemoteNotificationTypeNewsstandContentAvailability
がないのが気になっております。iOS8の場合はこれに該当するものがありませんでした。
サーバ側はrubyのgem「Grocer」を使っております。
ruby
1 2# 以下の方法と、 3notification = Grocer::Notification.new( 4 device_token: "fe15a27d5df3c34778defb1f4f3880265cc52c0c047682223be59fb68500a9a2", 5 alert: "Hello from Grocer!", 6 badge: 42, 7 category: "a category", # optional; used for custom notification actions 8 sound: "siren.aiff", # optional 9 expiry: Time.now + 60*60, # optional; 0 is default, meaning the message is not stored 10 identifier: 1234, # optional; must be an integer 11 content_available: true, # optional; any truthy value will set 'content-available' to 1 12 mutable_content: true # optional; any truthy value will set 'mutable-content' to 1 13) 14pusher.push(notification) 15 16# 以下の方法の両方試しましたが、結果は同じでした。 17 18notification = Grocer::NewsstandNotification.new(device_token: "...") 19pusher.push(notification)
同様の現象に出くわして解決された方はいらっしゃいませんか?
iOS (iPad) 8.4.1(12H321)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。