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?

Kathiresan Murugan
  • 2,783
  • 3
  • 23
  • 44
Maz
  • 245
  • 3
  • 11
  • 1
    Have you replaced the `Your Development App ...` placeholder text with your actual app Keys and Secrets? (don't paste them here - just confirm) – DonMag Jul 07 '17 at 17:29
  • thanks for replying, no i havent, I really dont know where to get that from, can you please tell me. – Maz Jul 07 '17 at 19:12
  • Did you follow everything here: https://docs.urbanairship.com/engage/getting-started/ and did you download their sample iOS Swift app? – DonMag Jul 07 '17 at 19:34
  • UAirship singleton will be nil if its not set up right. Follow what @DonMag suggested and you should be good to go. – ralepinski Jul 13 '17 at 22:45
  • Note: Airship's onboarding process has a UX bug (as of May 16, 2019). You view the app Keys and Secret until you finish the "Getting started" tutorial, but you need these to successfully send a push notification, which is the last step. To get around this just tap the send pushbutton and click the "I received the notificaiton" checkbox. You will then be able to access the dashboard where you can view the keys in Setting>APIs & Integrations – TMin May 16 '19 at 19:50

1 Answers1

1

useWKWebView seems to be long invalid:

2018-12-11 15:32:10.228876+0300 V4 P97 Dev[4468:2691527] [D] -[UAConfig setValue:forUndefinedKey:] [Line 404] Ignoring invalid UAConfig key: useWKWebView

probably it's on by default though you can't tell by the size of the font inside that WKWebView ;^)

Anton Tropashko
  • 5,486
  • 5
  • 41
  • 66