Giter Club home page Giter Club logo

Comments (15)

LudoFarkas avatar LudoFarkas commented on July 19, 2024

Update:

We have tested this issue with different devices and it apparently occurs on Xiaomi devices (or devices with MIUI OS). The problem is their "Display pop-up windows while running in the background" permission, which needs to be enabled in order to open the app from Exponea notification. But it is not intuitive for the user to go to the settings and enable it.

However, if we send our own notification with a deeplink, everything is working as expected, irrespective of the setting of the "Display pop-up windows ..." permission.

Could you please look into this?

IMG_20220328_104843

from exponea-android-sdk.

michaela-dev avatar michaela-dev commented on July 19, 2024

Hi, thanks for the update! We are aware that Xiaomi Devices with MIUI OS have various issues with push actions when the app is stopped/killed, but it's new to us this is happening also when the app is in the background. Can you please send some example of the notification payload you are sending yourself? It would be very helpful 🙏 thanks!

from exponea-android-sdk.

LudoFarkas avatar LudoFarkas commented on July 19, 2024

The payload looks like (the URL is redacted):

{
    "action": "deeplink",
    "actions": [
        {
            "title": "More",
            "action": "deeplink",
            "url": "foo://deeplink/to/the/app"
        }
    ],
    "title": "Deeplink test",
    "message": "Push notification with a deeplink to the app.",
    "url": "foo://deeplink/to/the/app"
}

from exponea-android-sdk.

michaela-dev avatar michaela-dev commented on July 19, 2024

Hi, I searched a bit and it is caused by MIUI 11+. It does not work well with pending intents which have a back stack configured. It is needed to request permission in order to support notifications with pending intent with configured navigation stack.

Some sources say, that this permission is granted automatically by google when the app has a target above 30 and is installed from google play, so it will not be granted when installed during development, but I am not able to verify this information. Others just recommend navigating the user to settings if MIUI is present and permission seems not to be granted.

Useful references:
https://stackoverflow.com/questions/59418504/xiaomi-devices-permission-to-enable-apps-pop-up-windows-while-running-in-the-bac
https://stackoverflow.com/questions/59214359/anyone-knows-where-is-start-in-background-permission-in-miui-11
https://stackoverflow.com/questions/59051867/permission-to-display-pop-up-windows-while-running-in-the-background

Since Exponea is sending exact same payload, I do not see how this can be handled on our side, and why it (according to your words) works without this permission, when you send the notification by yourself 🤔 are you trying both options on the same environment?

I will dig some more, but it can take some time.

from exponea-android-sdk.

LudoFarkas avatar LudoFarkas commented on July 19, 2024

I have found those SO resources too. But I too cannot confirm that the permission is granted automatically by the Play Store, because the updated app is not live yet.

We have also our own notification sending mechanism except Exponea, that we use for sending other notifications to our app. That is why we have our own notification displaying mechanism which works when navigating to a deeplink when the app is in stopped or in background. Our pending intent creation code looks like:

private fun createPendingIntent(context: Context, id: Int, deeplink: String?): PendingIntent {
        val intent = Intent(context, MainActivity::class.java).apply {
            if (deeplink != null) data = Uri.parse(deeplink)
        }
        return PendingIntent.getActivity(context, id, intent, createPendingIntentFlagUpdateCurrentCompat())
    }

    private fun createPendingIntentFlagUpdateCurrentCompat(): Int {
        return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
        } else {
            PendingIntent.FLAG_UPDATE_CURRENT
        }
    }

I tested it on the exact same build of app as the non-functioning Exponea notification. The older Exponea ver. 2.9.5 worked as expected also without the extra permission.

from exponea-android-sdk.

michaela-dev avatar michaela-dev commented on July 19, 2024

Many thanks for your investigation! We will check pending intent creation in SDK and will try to make some changes to make it work. How pressing is this for you? We will be able to get to this maybe sometime next week since other work is in progress.

from exponea-android-sdk.

LudoFarkas avatar LudoFarkas commented on July 19, 2024

Well, our plan to have the update in the Play Store is in 2 weeks from now, so next week could work I guess.
Thanks for looking into it.

from exponea-android-sdk.

michaela-dev avatar michaela-dev commented on July 19, 2024

Okay, I will make it a priority next week. One more question, does this problem occur only with deep link action sent from the Exponea? Or open app/open web browser actions are also problematic? Or you do not use these?

from exponea-android-sdk.

LudoFarkas avatar LudoFarkas commented on July 19, 2024

We generally do not use the open app action as far as I know. But I did a quick test and it does not work when the app is in background or stopped. The open browser action works as intended.

from exponea-android-sdk.

michaela-dev avatar michaela-dev commented on July 19, 2024

Hi, Thanks for the testing 👍 Unfortunately, I am currently not able to reproduce this issue with multiple Xiaomi devices with MIUI 🤔 on what MIUI version are you facing this issue?

from exponea-android-sdk.

LudoFarkas avatar LudoFarkas commented on July 19, 2024

Hi, we have 2 devices with MIUI and the issue is present on both of them:

  1. Xiaomi Mi 9 with MIUI Global 12.5.1 (Android 11)
  2. Redmi Note 8T with MIUI Global 11.0.3 (Android 9)

However, there is one strange thing happening.
If there are 2 instances of the app installed on a device (2 different packages, but same intent filter to capture deeplinks), the "Open with..." dialog pops up and if I choose one of them, it opens and works. If just 1 app is installed (no "Open with..." dialog), the deeplink is not routed to the app if it is off or in background (as stated in previous comments) 🤷

from exponea-android-sdk.

michaela-dev avatar michaela-dev commented on July 19, 2024

I was finally able to reproduce. What I do not understand is that our example app gets the permission automatically during installation, and I have to turn it off manually to reproduce. The issue is definitely caused by MIUI 11+ not working well with pending intents that have a back stack configured if this permission is denied in settings. Unfortunately, because of Android 12 requirements, we were forced to use back stack pending intents to be able to start push notification actions and keep tracking them. I understand it's not intuitive for the Xiaomi users to go and switch this permission on, to make this work, but I am afraid we can not switch back to simple pending intent because of this, since it would break the core functionality of the SDK for apps targeting Android 12. Can you maybe consider navigating the users to this setting and request them to turn it on, if they are using a Xiaomi device? It's not ideal, but since this is MIUI specific issue, maybe it would be the best solution for now, and when your app will be released, you can check if this permission was granted automatically. Let me know if I can be of any more help.

from exponea-android-sdk.

LudoFarkas avatar LudoFarkas commented on July 19, 2024

Thanks for looking into it. I guess we'll just wait until the app gets released if it gets the permission automatically when installed from the Play store. If not, then we'll discuss if we should incorporate a banner or note for MIUI users.

from exponea-android-sdk.

adam1929 avatar adam1929 commented on July 19, 2024

@LudoFarkas Hi, feel free to summarize your solution here. Other developer may be finding your solution. Thank you.

from exponea-android-sdk.

LudoFarkas avatar LudoFarkas commented on July 19, 2024

Hi. If the app is installed from the Play Store, it does not get the permission automatically. So the only solution we found is navigating the users to settings and request them to turn it on, if on a MIUI device.
I am closing this, since there is no action on your side.

from exponea-android-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.