unexpectedly found nil while unwrapping an Optional value - SWIFT 3

I created a new urbanairship account and i followed all the documentation stated on their link but when i setup the AppDelegate part as they mentioned:

func application(_ application: UIApplication,
                 didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    let config = UAConfig.default();
    UAirship.takeOff(config);
    UAirship.push().defaultPresentationOptions = [.alert, .badge, .sound]
    UAirship.push().userPushNotificationsEnabled = true;
    return true;
}

my code crashes on UAirship.push().defaultPresentationOptions = [.alert, .badge, .sound] saying: fatal error: unexpectedly found nil while unwrapping an Optional value.

I debugged and found out that UAirship.push() is resulting in a nil.

Also note that i have created the AirshipConfig pList file as requested on the same page and i have pasted the following:

<plist version="1.0">
<dict>
    <key>developmentAppKey</key>
    <string>Your Development App Key</string>
    <key>developmentAppSecret</key>
    <string>Your Development App Secret</string>
    <key>productionAppKey</key>
    <string>Your Production App Key</string>
    <key>productionAppSecret</key>
    <string>Your Production App Secret</string>
    <key>useWKWebView</key>
    <true/>
</dict>

 

Can somebody tell me what im doing wrong here?

Didn't find what you were looking for?

New post

Comments

3 comments

  • Hi Mazen,

    In your AirshipConfig.plist, I wanted to make sure that you've filled in the values "Your Development App Key" and "Your Development App Secret"? 

    These keys can be found in your Urban Airship dashboard under Settings-> APIs & Integrations. You'll need to take those keys and input them into the plist for the SDK to be able to communicate to the correct app on your account.

     

    Comment actions Permalink
    1
  • Thanks Michael, its really unclear how to get to the Settings, I started the QuickGuide and I had to press i received the message though i didnt before it took me to the real dashboard. Doesnt make sense. Its working now that i have the Keys and Secret.

     

    Thank.

    Comment actions Permalink
    0
  • Mazen,

    The quickstart guide should have had instructions for you to follow to have the correct Plist file in your app. If you've not successfully received the message, I would not continue to the dashboard until you were able to receive it properly.

    Comment actions Permalink
    0

Please sign in to leave a comment.