私は最近、アプリケーションで通知を設定しました。私はPHP経由で送信できますが、心配する必要はありません。すべて正常に動作します。通知iOsプッシュは配信されましたか?
先週以来、私はプッシュ通知は電話か...
によって受信されたかどうかを確認しようとしています誰かがそれをクリックしたときに私が知ることができますが、人はそれをクリックし、好むていない場合アプリケーションを開くには、それは動作しません..
アプリケーションが通知を受信したばかりのことを教えてくれる簡単な関数はありませんか?私AppDelegate.swiftで
:
import UIKit
import UserNotifications
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
...
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Check if launched from notification
if let notification = launchOptions?[UIApplicationLaunchOptionsKey.remoteNotification] as? [String: AnyObject] {
//print(notification)
window?.rootViewController?.present(ViewController(), animated: true, completion: nil)
}
else{
//print("ici ?")
registerForRemoteNotification()
}
return true
}
...
//Called when a notification is delivered to a foreground app.
@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.alert, .badge, .sound])
}
//Called to let your app know which action was selected by the user for a given notification.
@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping() -> Void) {
completionHandler()
}
...
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
**print("here ?")**
switch((application.applicationState)){
case UIApplicationState.inactive:
print("Inactive")
//Show the view with the content of the push
completionHandler(.newData)
case UIApplicationState.background:
print("Background")
//Refresh the local model
completionHandler(.newData)
default:
print("Active")
//Show an in-app banner
completionHandler(.newData)
break
}
}
}
問題:私はdidReceiveRemoteNotificationに渡すことはありません:/ "ここに印刷" が表示されることはありません。
私は、この行に間違いがありますInstance method 'application(application:didReceiveRemoteNotification:fetchCompletionHandler:)' nearly matches optional requirement 'application(_:didReceiveRemoteNotification:fetchCompletionHandler:)' of protocol 'UIApplicationDelegate'
しかし、私は理解していない:/
あなたのアイデアを持っていますか?あなたの助けのための
Thxを^^
、唯一の我々は、通知をタップし、ユーザーを確認することができます。ユーザーが通知をスヌープすると、この機能はAppleのドキュメントでは利用できません。 – Pavankumar
私のアプリがプッシュを受け取るかどうかを確認することはできませんか? O_o – Insou
http://stackoverflow.com/questions/25830597/how-to-know-push-notification-delivery-status、リンクを参照してくださいと私はまた、配信されたかどうかを言う保証を勉強した。私たちのアプリでも、私たちはこの1つを試してみました。 – Pavankumar