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.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">
    <string>Your Development App Key</string>
    <string>Your Development App Secret</string>
    <string>Your Production App Key</string>
    <string>Your Production App Secret</string>


Can somebody tell me what im doing wrong here?

Didn't find what you were looking for?

New post



  • 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
  • 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.



    Comment actions Permalink
  • 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

Please sign in to leave a comment.