2

I created app in which i don't want to get notification on emulator. I want FCM Push notification in real device only. So how to restrict notification on emulator, bluestacks, Genymotion or some others emulator?

I searched on Google, but I didn't get any solution. So If I miss something please provide that link.

AL.
  • 36,815
  • 10
  • 142
  • 281
a.dev
  • 207
  • 2
  • 11
  • 1
    just don't subscribe to firebase notifications if the app launches on emulator. see this topic http://stackoverflow.com/questions/2799097/how-can-i-detect-when-an-android-application-is-running-in-the-emulator – shagi Apr 14 '17 at 06:44
  • Does that help to detect all of [this](http://www.androidauthority.com/best-android-emulators-for-pc-655308/) ? – a.dev Apr 14 '17 at 06:46
  • should be so. but it can possibly depends on emulator developers. – shagi Apr 14 '17 at 06:53
  • Ya exactly .I can't go and check every time on live app if some new emulator is launch. – a.dev Apr 14 '17 at 06:57

1 Answers1

0

just don't subscribe to firebase notifications if the app launches on emulator.

public static boolean isEmulator() {
        return Build.FINGERPRINT.startsWith("generic")
                || Build.FINGERPRINT.startsWith("unknown")
                || Build.MODEL.contains("google_sdk")
                || Build.MODEL.contains("Emulator")
                || Build.MODEL.contains("Android SDK built for x86")
                || Build.MANUFACTURER.contains("Genymotion")
                || (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"))
                || "google_sdk".equals(Build.PRODUCT);
    }

also u can find some other methods in this topic How can I detect when an Android application is running in the emulator?

Community
  • 1
  • 1
shagi
  • 629
  • 8
  • 25