iOSのアプリ開発を行っていて、voipプッシュ通知の実装をしようとしています。
方法としては、アプリ起動時に受け取ったデバイストークンでAWSのSNS機能を使って送信を行うというものになります。
通常のプッシュ通知はAWS SNS上で送信成功して、デバイス側にも通知はくるのですが、
voipプッシュ通知を送信した時にはAWS SNS上で送信成功していますが、swift側でバックグラウンドで動くはずのメソッドが実行されません。
AppleDelegate.swiftは以下のようにしていて、
設定ではSigning&CapabilitiesでBackground Modesのvoice over IPにチェックを入れています。
AppDelegate.swift
import UIKit import CoreData import UserNotifications import PushKit import Alamofire import CallKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? var skywayAPIKey:String? = "..." var skywayDomain:String? = "..." var backgroundTaskID = UIBackgroundTaskIdentifier.invalid var timer: Timer? var pushRegistry:PKPushRegistry! class var shared: AppDelegate { return UIApplication.shared.delegate as! AppDelegate } func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { pushRegistry = PKPushRegistry(queue: nil) pushRegistry.delegate = self // PKPushRegistryDelegateを採用していす pushRegistry.desiredPushTypes = Set([PKPushType.voIP]) return true } ...略... } extension AppDelegate: PKPushRegistryDelegate { func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) { let pkid = pushCredentials.token.map { String(format: "%02.2hhx", $0) }.joined() print("your device token:(pkid)") } func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) { guard type == .voIP else { return } print("received voip!!!!!!!!!!!!!!!!!!!") } }
your device token: ... は出力されますが、received voip!!!!!!!!!!!!!!!!!!!は出力されません。
ちなみに、バージョンは以下になります
swift version 5.0.1 xcode 11.0
これで一週間以上詰まっています。
何かアドバイスや解決方法を教えていただければ幸いです。
よろしくお願いします!
あなたの回答
tips
プレビュー