0

I implemented a toast with to open an url.

Here's the toast:

<toast> <visual><binding template='ToastGeneric'><text>Go To bing.com</text></binding></visual></toast>

After that I added the handling to the OnStartAsync-Method:

public override Task OnStartAsync(StartKind startKind, IActivatedEventArgs args)
{
    // navigates to Splash-Page
    NavigationHelper.NavigationService = NavigationService;
    NavigationService.Navigate(typeof(SplashPage));
    // open the url
    if (args is ToastNotificationActivatedEventArgs)
    {
        Windows.System.Launcher.LaunchUriAsync(new Uri("http://www.bing.com"));
    }
    return Task.FromResult<object>(null);
}

unfortunately the App crashes on the phone (it works like a charm on a desktop machine) every time I open the app with a tap on a notification with the following exeption (If I start the app without a tap on a notification, the normal way, it doesn't crash):

$exception  {"Object reference not set to an instance of an object."}   System.NullReferenceException

With the following stacktrace:

at Template10.Common.BootStrapper.<HandleResuming>d__99.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.ThrowAsync>b__6_0(Object state)
at System.Threading.WinRTSynchronizationContext.Invoker.InvokeCore()
at Windows.ApplicationModel.Core.UnhandledError.Propagate()
at Microsoft.HockeyApp.Extensibility.Windows.UnhandledExceptionTelemetryModule.CoreApplication_UnhandledErrorDetected(Object sender, UnhandledErrorDetectedEventArgs e)"    string

I can't figure out the problem by myself and need some help right here.

If I remove the line with the Launch the app doesn't crash.

sk2andy
  • 749
  • 1
  • 8
  • 19
  • When you open App by tapping on Toast, what is `args`. is it empty? or is it coming in with some data? – AVK Sep 08 '16 at 14:15
  • @AVKNaidu There are args (ToastNotificationActivatedEventArgs). I am also able to access the launch-attribute when I add it to the toast – sk2andy Sep 08 '16 at 14:22
  • Ok. Based on the code that you showed us, You want to tap the Notification, and when the App is starting ( Bear in Mind, The app did not completely Launch Yet ) you want to move away from your app and Open a Browser to show a web page? – AVK Sep 08 '16 at 14:40
  • Yes, that's correct – sk2andy Sep 08 '16 at 14:47
  • Try the below cases. try Navigating to browser before Navigating to SplashPage. See if it works. If it does not, Pass args as parameter to SplashPage and then try to launch browser from SplashPage see if it works – AVK Sep 08 '16 at 15:25
  • What is your template 10 version and your mobile os build? I can't reproduce this issue. You can try to update your template 10 version to the newest one. – Grace Feng Sep 09 '16 at 07:44

0 Answers0