• <small id='kCOE3'></small><noframes id='kCOE3'>

    1. <tfoot id='kCOE3'></tfoot>
        <bdo id='kCOE3'></bdo><ul id='kCOE3'></ul>
      <legend id='kCOE3'><style id='kCOE3'><dir id='kCOE3'><q id='kCOE3'></q></dir></style></legend>
    2. <i id='kCOE3'><tr id='kCOE3'><dt id='kCOE3'><q id='kCOE3'><span id='kCOE3'><b id='kCOE3'><form id='kCOE3'><ins id='kCOE3'></ins><ul id='kCOE3'></ul><sub id='kCOE3'></sub></form><legend id='kCOE3'></legend><bdo id='kCOE3'><pre id='kCOE3'><center id='kCOE3'></center></pre></bdo></b><th id='kCOE3'></th></span></q></dt></tr></i><div id='kCOE3'><tfoot id='kCOE3'></tfoot><dl id='kCOE3'><fieldset id='kCOE3'></fieldset></dl></div>

      1. 点击通知时如何处理 Swift 3 中的启动选项?遇到语法问题

        How to handle launch options in Swift 3 when a notification is tapped? Getting syntax problems(点击通知时如何处理 Swift 3 中的启动选项?遇到语法问题)

          <small id='2R0fU'></small><noframes id='2R0fU'>

            <tbody id='2R0fU'></tbody>

                <bdo id='2R0fU'></bdo><ul id='2R0fU'></ul>

              • <tfoot id='2R0fU'></tfoot>
                <legend id='2R0fU'><style id='2R0fU'><dir id='2R0fU'><q id='2R0fU'></q></dir></style></legend>
                  <i id='2R0fU'><tr id='2R0fU'><dt id='2R0fU'><q id='2R0fU'><span id='2R0fU'><b id='2R0fU'><form id='2R0fU'><ins id='2R0fU'></ins><ul id='2R0fU'></ul><sub id='2R0fU'></sub></form><legend id='2R0fU'></legend><bdo id='2R0fU'><pre id='2R0fU'><center id='2R0fU'></center></pre></bdo></b><th id='2R0fU'></th></span></q></dt></tr></i><div id='2R0fU'><tfoot id='2R0fU'></tfoot><dl id='2R0fU'><fieldset id='2R0fU'></fieldset></dl></div>
                1. 本文介绍了点击通知时如何处理 Swift 3 中的启动选项?遇到语法问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试处理启动选项并在点击我在 swift 3 中收到的远程通知时打开一个特定的视图控制器.我看到了类似的问题,例如 这里,但对于新的 swift 3 实施没有任何帮助.我在 AppDelegate.swift 中看到了一个类似的问题(和)我在 didFinishLaunchingWithOptions 中有以下内容:

                  I am trying to handle the launch option and open a specific view controller upon tapping a remote notification that I receive in swift 3. I have seen similar question, for instance here, but nothing for the new swift 3 implementation. I saw a similar question (and ) In AppDelegate.swift I have the following in didFinishLaunchingWithOptions:

                      var localNotif = (launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey] as! String)
                  if localNotif {
                      var itemName = (localNotif.userInfo!["aps"] as! String)
                      print("Custom: (itemName)")
                  }
                  else {
                      print("//////////////////////////")
                  }
                  

                  但是 Xcode 给了我这个错误:

                  but Xcode is giving me this error:

                  Type '[NSObject: AnyObject]?' has no subscript members
                  

                  我也试过这个:

                     if let launchOptions = launchOptions {
                          var notificationPayload: NSDictionary = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey] as NSDictionary!
                  
                      }
                  

                  我得到这个错误:

                  error: ambiguous reference to member 'subscript'
                  

                  我以前使用类似代码通过键从字典中获取值的任何地方都遇到了类似的错误,我必须替换代码并首先安全地解开字典.但这似乎在这里不起作用.任何帮助,将不胜感激.谢谢.

                  I got similar errors wherever I had previously used similar code to get a value from a dictionary by the key and I had to replace the codes and basically safely unwrap the dictionary first. But that doesn't seem to work here. Any help would be appreciated. Thanks.

                  推荐答案

                  结果发现整个方法签名已经改变,当我实现新的签名时一切正常.下面是代码.

                  So it turned out the whole method signature has changed and when I implemented the new signature things worked just fine. Below is the code.

                  新的 didFinishLaunchingWithOptions 方法:

                  new didFinishLaunchingWithOptions method:

                  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
                  
                  
                  
                  //and then 
                   if launchOptions?[UIApplicationLaunchOptionsKey.remoteNotification] != nil {
                  
                  
                  // Do what you want to happen when a remote notification is tapped.
                  
                  
                  }
                  
                  }
                  

                  希望这会有所帮助.

                  这篇关于点击通知时如何处理 Swift 3 中的启动选项?遇到语法问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  When does a FCM token expire?(FCM 令牌何时到期?)
                  Firebase Cloud Messaging (FCM) - Launch Activity when user clicks the notification with extras(Firebase Cloud Messaging (FCM) - 当用户点击带有附加功能的通知时启动活动)
                  Implement Firebase inside of a Library(在库中实现 Firebase)
                  Firebase Backward compatibility with GCM(Firebase 与 GCM 的向后兼容性)
                  Receiving the FCM notifications multiple times on Nougat(在 Nougat 上多次接收 FCM 通知)
                  Push Notifications are delivered but didReceiveRemoteNotification is never called Swift(推送通知已交付,但 didReceiveRemoteNotification 从未被称为 Swift)

                2. <i id='6gV54'><tr id='6gV54'><dt id='6gV54'><q id='6gV54'><span id='6gV54'><b id='6gV54'><form id='6gV54'><ins id='6gV54'></ins><ul id='6gV54'></ul><sub id='6gV54'></sub></form><legend id='6gV54'></legend><bdo id='6gV54'><pre id='6gV54'><center id='6gV54'></center></pre></bdo></b><th id='6gV54'></th></span></q></dt></tr></i><div id='6gV54'><tfoot id='6gV54'></tfoot><dl id='6gV54'><fieldset id='6gV54'></fieldset></dl></div>

                  <small id='6gV54'></small><noframes id='6gV54'>

                  <tfoot id='6gV54'></tfoot>

                3. <legend id='6gV54'><style id='6gV54'><dir id='6gV54'><q id='6gV54'></q></dir></style></legend>

                            <tbody id='6gV54'></tbody>
                            <bdo id='6gV54'></bdo><ul id='6gV54'></ul>