Xamarin Forms iOS app crashing few seconds after startup

Hello!

Every time I run my app with Urban Airship SDK on my phone, it crashes after a few seconds with this error:


My AppDelegate.cs:

[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();

LoadApplication(new App());

UIApplication.SharedApplication.SetStatusBarStyle(UIStatusBarStyle.LightContent, false);

UAirship.TakeOff();
UAirship.Push.UserPushNotificationsEnabled = true;

return base.FinishedLaunching(app, options);
}

}

 

My AirshipConfig.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>detectProvisioningMode</key>
<true/>
<key>developmentAppKey</key>
<string>aVf7WPfwSwCV2_n3ki3cIQ</string>
<key>developmentAppSecret</key>
<string>r6d2ayBZS-S4QBOnH3-rqQ</string>
<key>productionAppKey</key>
<string>Your Production App Key</string>
<key>productionAppSecret</key>
<string>Your Production App Secret</string>
</dict>
</plist>

Didn't find what you were looking for?

New post

Comments

9 comments

  • Hello Luca!

    Can you confirm what version of Xamarin.Forms you're using to build this app? Are you on the latest version?

    Can you also confirm that you have set up Visual Studio and Xamarin.Forms with your Mac according to Xamarin's setup instructions?

    Comment actions Permalink
    0
  • Hello Michael,

    I can confirm both of these, I updated yesterday and the app works perfectly without the urban airship sdk.

    Comment actions Permalink
    0
  • Luca,

    Do you perhaps happen to have logs from running the app on your device?

    I'm curious if the app is crashing because you have not defined the Production App Key or Secret in the plist file. 

    If detectProvisioningMode is turned on, the app is going to try and determine which set of app keys (Development or Production) to use based off of the provisioning profile. So, I'm wondering if perhaps it might be using the Production version. If it is, then it is going to try and use the Production app keys, and it won't work properly if the app keys are not valid.

    Comment actions Permalink
    0
  • Michael,

    Where can I find these logs?

    Comment actions Permalink
    0
  • Luca,

    The logs should be what Visual Studio prints out to you in the Console Logs.

    Comment actions Permalink
    0
  • Michael,

     

    Launching 'ServerAdmin.iOS' on 'Luca's iPhone'...
    Loaded assembly: /private/var/containers/Bundle/Application/1B3A35D3-8451-45D1-9673-C85D6173E1A0/ServerAdmin.iOS.app/.monotouch-64/System.dll
    Loaded assembly: /private/var/containers/Bundle/Application/1B3A35D3-8451-45D1-9673-C85D6173E1A0/ServerAdmin.iOS.app/.monotouch-64/Mono.Dynamic.Interpreter.dll [External]
    Loaded assembly: /private/var/containers/Bundle/Application/1B3A35D3-8451-45D1-9673-C85D6173E1A0/ServerAdmin.iOS.app/.monotouch-64/System.Core.dll
    Loaded assembly: /private/var/containers/Bundle/Application/1B3A35D3-8451-45D1-9673-C85D6173E1A0/ServerAdmin.iOS.app/.monotouch-64/Xamarin.iOS.dll
    Launch succeeded. The app 'ServerAdmin.iOS' has been successfully launched on 'Luca's iPhone'.
    Loaded assembly: /private/var/containers/Bundle/Application/1B3A35D3-8451-45D1-9673-C85D6173E1A0/ServerAdmin.iOS.app/.monotouch-64/System.Xml.dll
    Loaded assembly: /private/var/containers/Bundle/Application/1B3A35D3-8451-45D1-9673-C85D6173E1A0/ServerAdmin.iOS.app/.monotouch-64/Xamarin.Forms.Platform.dll
    Loaded assembly: /private/var/containers/Bundle/Application/1B3A35D3-8451-45D1-9673-C85D6173E1A0/ServerAdmin.iOS.app/.monotouch-64/Xamarin.Forms.Core.dll
    Loaded assembly: /private/var/containers/Bundle/Application/1B3A35D3-8451-45D1-9673-C85D6173E1A0/ServerAdmin.iOS.app/.monotouch-64/System.Net.Http.dll
    Loaded assembly: /private/var/containers/Bundle/Application/1B3A35D3-8451-45D1-9673-C85D6173E1A0/ServerAdmin.iOS.app/.monotouch-64/System.ServiceModel.Internals.dll [External]
    Loaded assembly: /private/var/containers/Bundle/Application/1B3A35D3-8451-45D1-9673-C85D6173E1A0/ServerAdmin.iOS.app/.monotouch-64/System.Runtime.Serialization.dll [External]
    Loaded assembly: /private/var/containers/Bundle/Application/1B3A35D3-8451-45D1-9673-C85D6173E1A0/ServerAdmin.iOS.app/.monotouch-64/Xamarin.Forms.Platform.iOS.dll
    Thread started: #2
    Loaded assembly: /private/var/containers/Bundle/Application/1B3A35D3-8451-45D1-9673-C85D6173E1A0/ServerAdmin.iOS.app/.monotouch-64/AirshipBindings.dll
    Loaded assembly: /private/var/containers/Bundle/Application/1B3A35D3-8451-45D1-9673-C85D6173E1A0/ServerAdmin.iOS.app/.monotouch-64/SQLitePCL.raw.dll
    Loaded assembly: /private/var/containers/Bundle/Application/1B3A35D3-8451-45D1-9673-C85D6173E1A0/ServerAdmin.iOS.app/.monotouch-64/SQLite-net.dll
    Loaded assembly: /private/var/containers/Bundle/Application/1B3A35D3-8451-45D1-9673-C85D6173E1A0/ServerAdmin.iOS.app/.monotouch-64/Xamarin.Forms.Xaml.dll
    Loaded assembly: /private/var/containers/Bundle/Application/1B3A35D3-8451-45D1-9673-C85D6173E1A0/ServerAdmin.iOS.app/.monotouch-64/System.Xml.Linq.dll [External]
    Loaded assembly: /private/var/containers/Bundle/Application/1B3A35D3-8451-45D1-9673-C85D6173E1A0/ServerAdmin.iOS.app/.monotouch-64/RestSharp.dll
    Loaded assembly: /private/var/containers/Bundle/Application/1B3A35D3-8451-45D1-9673-C85D6173E1A0/ServerAdmin.iOS.app/.monotouch-64/Parse.iOS.dll
    Loaded assembly: /private/var/containers/Bundle/Application/1B3A35D3-8451-45D1-9673-C85D6173E1A0/ServerAdmin.iOS.app/.monotouch-64/Newtonsoft.Json.dll
    Loaded assembly: /private/var/containers/Bundle/Application/1B3A35D3-8451-45D1-9673-C85D6173E1A0/ServerAdmin.iOS.app/.monotouch-64/ServerAdmin.iOS.exe
    Thread started: #3
    Thread started: #4
    Thread started: <Thread Pool> #5
    Thread started: <Thread Pool> #6
    Thread started: <Thread Pool> #7
    2016-11-14 21:01:30.897 ServerAdmin.iOS[3035:750302] Testing parse...
    Resolved pending breakpoint at 'ServerListPage.xaml.cs:51,1' to void ServerAdmin.ServerListPage.<testParse>d__2.MoveNext () [0x000b4].
    2016-11-14 21:01:31.469 ServerAdmin.iOS[3035:750302] [W] -[UAConfig validate] [Line 239] Production App Key is not valid.
    2016-11-14 21:01:31.469 ServerAdmin.iOS[3035:750302] [W] -[UAConfig validate] [Line 243] Production App Secret is not valid.
    2016-11-14 21:01:31.469 ServerAdmin.iOS[3035:750302] [I] +[UAirship executeUnsafeTakeOff:] [Line 201] UAirship Take Off! Lib Version: 8.0.2 App Key: aVf7WPfwSwCV2_n3ki3cIQ Production: NO.
    2016-11-14 21:01:31.471 ServerAdmin.iOS[3035:750302] [D] +[UAirship executeUnsafeTakeOff:] [Line 209] Setting User-Agent for UA requests to ServerAdmin 1.1 (iPhone; iOS 10.1.1; UALib 8.0.2; aVf7WPfwSwCV2_n3ki3cIQ; nl_NL)
    2016-11-14 21:01:31.540 ServerAdmin.iOS[3035:750302] [D] -[UANamedUser update] [Line 83] New or re-install, skipping named user update.
    2016-11-14 21:01:31.576 ServerAdmin.iOS[3035:750302] [D] -[UADefaultMessageCenterStyle setValue:forUndefinedKey:] [Line 164] Ignoring invalid UAMessageCenterDefaultStyle key: detectProvisioningMode
    2016-11-14 21:01:31.576 ServerAdmin.iOS[3035:750302] [D] -[UADefaultMessageCenterStyle setValue:forUndefinedKey:] [Line 164] Ignoring invalid UAMessageCenterDefaultStyle key: developmentAppKey
    2016-11-14 21:01:31.576 ServerAdmin.iOS[3035:750302] [D] -[UADefaultMessageCenterStyle setValue:forUndefinedKey:] [Line 164] Ignoring invalid UAMessageCenterDefaultStyle key: productionAppSecret
    2016-11-14 21:01:31.576 ServerAdmin.iOS[3035:750302] [D] -[UADefaultMessageCenterStyle setValue:forUndefinedKey:] [Line 164] Ignoring invalid UAMessageCenterDefaultStyle key: developmentAppSecret
    2016-11-14 21:01:31.577 ServerAdmin.iOS[3035:750302] [D] -[UADefaultMessageCenterStyle setValue:forUndefinedKey:] [Line 164] Ignoring invalid UAMessageCenterDefaultStyle key: productionAppKey
    2016-11-14 21:01:31.577 ServerAdmin.iOS[3035:750302] [I] +[UAirship executeUnsafeTakeOff:] [Line 278] Automatic setup enabled.
    2016-11-14 21:01:31.578 ServerAdmin.iOS[3035:750302] [D] -[UAAutoIntegration swizzle:implementation:class:] [Line 161] Adding implementation for application:didRegisterForRemoteNotificationsWithDeviceToken: class AppDelegate
    2016-11-14 21:01:31.578 ServerAdmin.iOS[3035:750302] [D] -[UAAutoIntegration swizzle:implementation:class:] [Line 161] Adding implementation for application:didFailToRegisterForRemoteNotificationsWithError: class AppDelegate
    2016-11-14 21:01:31.578 ServerAdmin.iOS[3035:750302] [D] -[UAAutoIntegration swizzle:implementation:class:] [Line 161] Adding implementation for application:didReceiveRemoteNotification:fetchCompletionHandler: class AppDelegate
    2016-11-14 21:01:31.578 ServerAdmin.iOS[3035:750302] [D] -[UAAutoIntegration swizzle:implementation:class:] [Line 154] Swizzling implementation for setDelegate: class UNUserNotificationCenter
    2016-11-14 21:01:31.580 ServerAdmin.iOS[3035:750302] [D] -[UAAutoIntegration swizzle:implementation:class:] [Line 161] Adding implementation for userNotificationCenter:willPresentNotification:withCompletionHandler: class UAAutoIntegrationDummyDelegate
    2016-11-14 21:01:31.580 ServerAdmin.iOS[3035:750302] [D] -[UAAutoIntegration swizzle:implementation:class:] [Line 161] Adding implementation for userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler: class UAAutoIntegrationDummyDelegate
    2016-11-14 21:01:32.209 ServerAdmin.iOS[3035:750302] [D] -[UAAnalytics addEvent:] [Line 237] Adding app_init event 3D7375E5-0C3F-4B08-A62E-E672339E034C.
    2016-11-14 21:01:32.210 ServerAdmin.iOS[3035:750302] [D] -[UAPush updateRegistration] [Line 687] APNS registration is out of date, updating.
    2016-11-14 21:01:32.256 ServerAdmin.iOS[3035:750342] [D] __81-[UAAPNSRegistration updateRegistrationWithOptions:categories:completionHandler:]_block_invoke [Line 82] Registering for user notification options 7.
    Unhandled Exception:

    System.ArgumentNullException: Value cannot be null.
    Parameter name: uriString

    Comment actions Permalink
    0
  • Thanks Luca.

    Can you also confirm that you have your provisioning profiles, and certificates set up correctly?

    Once you confirm that, can you also try the following instead?:

    UAConfig Config = UAConfig.DefaultConfig();

    Config.DevelopmentAppKey = "App Key";
    Config.DevelopmentAppSecret = "App Secret";
    Config.DetectProvisioningMode = true;

    UAirship.TakeOff(Config);

    Comment actions Permalink
    0
  • This solved it, thank you! 

    Comment actions Permalink
    0
  • No problem!

    Comment actions Permalink
    0

Please sign in to leave a comment.