簡體   English   中英

應用程序打開時如何接收應用內推送通知?

[英]How to receive in - app push notifications when app is open?

我目前正在使用一個名為“whisper”的庫,它可以幫助顯示應用程序內推送通知Whisper Link

在我的“didReceiveRemoteNotification”中,我將其設置如下:

  func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
    if application.applicationState == .Active {

      let navigationController = self.window!.rootViewController as! UINavigationController

      if let aps = userInfo["aps"] as? NSDictionary {
        if let alert = aps["alert"] as? NSDictionary {
          if let title = alert["title"] as? NSString {
            if let body = alert["body"] as? NSString {

              let announcement = Announcement(title: title as! String, subtitle: body as! String, image: UIImage(named: "HolyGrailLogo-58"))
              Shout(announcement, to: navigationController)
            }

          }
        }
      }

      // Show and hide a message after delay


    }
  }

由於一些奇怪的原因,我沒有收到任何推送通知,不知道為什么。

  1. 檢查您的應用可以接收遠程通知的設備設置。
  2. 在此方法func應用程序之后放置一個print語句(application:UIApplication,didReceiveRemoteNotification。
  3. 如果它不是打印,則問題在於您的庫。
  4. 。不需要進行活動檢查。 當app在后台時,此方法將不會執行。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM