• <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 中的启动选项?遇到语法问题

        时间:2023-07-29

          <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 中的启动选项?遇到语法问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 android 中将 Map 转换为 Bundle 下一篇:FCM Token 会像 GCM 注册 ID 一样定期变化吗?

                  相关文章

                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>

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