Dishant
Dishant

Reputation: 1595

How to check if UWP App is running in Simulator or not?

In my UWP App, I have a push notification code which triggers whenever Application starts but as notification is not supported while running in Simulator(MSDN) my app always crashes. Is there any way to identify whether App is running in the simulator or not?

Upvotes: 0

Views: 242

Answers (1)

Martin Zikmund
Martin Zikmund

Reputation: 39082

I don't think there is a way to tell if the environment is Simulator. You could create a new build configuration and add a compilation flag like SIMULATOR and then disable the code that causes the crash in this configuration:

#if !SIMULATOR
   //your push notification code
#endif

Upvotes: 2

Related Questions