title: How to handle launch options in Swift 3 when a notification is tapped? Getting syntax problems
body: <p>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 <a href="https://stackoverflow.com/questions/20757362/open-a-view-controller-when-a-ios-push-notification-is-received">here</a>, but nothing for the new swift 3 implementation. I saw a similar question (and ) In AppDelegate.swift I have the following in didFinishLaunchingWithOptions: </p>
  
  <pre><code>    var localNotif = (launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey] as! String)
  if localNotif {
      var itemName = (localNotif.userInfo!["aps"] as! String)
      print("Custom: \(itemName)")
  }
  else {
      print("//////////////////////////")
  }
  </code></pre>
  
  <p>but Xcode is giving me this error: </p>
  
  <pre><code>Type '[NSObject: AnyObject]?' has no subscript members
  </code></pre>
  
  <p>I also tried this: </p>
  
  <pre><code>   if let launchOptions = launchOptions {
          var notificationPayload: NSDictionary = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey] as NSDictionary!
  
      }
  </code></pre>
  
  <p>and I get this error: </p>
  
  <pre><code>error: ambiguous reference to member 'subscript'
  </code></pre>
  
  <p>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.  </p>