exponea / exponea-react-native-sdk

MIT License
8 stars 13 forks source link

Can't get the AppInboxButton to open the inbox #111

Closed StuartPyper closed 8 months ago

StuartPyper commented 10 months ago

Hi, I'm having issues getting the inbox to open, adding <AppInboxButton style={{ width: '60%', height: 60, }} /> to the page I can see the button shown but there seems to be no function attached to it as pressing the button has no affect.

Can you please tell me what function it should use or that I can trigger from a custom button if needs be?

Note: If I run:

Exponea.fetchAppInbox()
  .then(list => {
    list.forEach(message => console.log(message))
  })
  .catch(error => console.log(error.message))

I can see that my user does have some messages in the inbox and that the SDK is initialised, I just can’t figure out how to get the standard inbox to open. Thanks.

adam1929 commented 10 months ago

Hi @StuartPyper thank you for reporting. We tested our Example application and AppInbox is showing correctly. Which platform is not working? Android or iOS or both? Did you import AppInboxButton from 'react-native-exponea-sdk/lib/AppInboxButton'; on your screen? I think yes, but I need to ask to eliminate this step. Do you see any related error logs in console? Button is working by same (or very similar) principle on both platforms. By clicking on it, Android will open a new Activity; iOS will open a new ViewController; both screens are added into "stack". Maybe there is an issue but logs should provide some error logs for this. Thank you

StuartPyper commented 10 months ago

I am working on both platforms but the latest test was on iOS. The import is indeed: import AppInboxButton from 'react-native-exponea-sdk/lib/AppInboxButton'; I see no errors, I have found that I if I press the button very quickly after app refresh then it works once but then it's as if the button disables itself for some reason then no longer functions. As mentioned, even after this happens I can still fire Exponea.fetchAppInbox() and see the inbox content but the AppInboxButton doesn't function. I'm finding it very hard to debug.

adam1929 commented 10 months ago

Hi @StuartPyper thank you for answer. I'm thinking of case that ReactNative is removing onClick listener from button. It is theory, but stay with me please. If you put AppInboxButton into screen, SDK will produce native button view and "returns" it to ReactNative view management. ReactNative could update styling, sizes, etc. according to your theming. These changes are reflected also into native view. Could you see any possibility of setting of disabled/enabled state of button from your app or layout management? Or any click listener assignment? This could explain also your 'works once but then it's as if the button disables itself' description. SDK produce native button but there is no 'disable/enable' feature implemented.

StuartPyper commented 10 months ago

No, I know of nothing inside our app that would listen to and or disable any buttons for any reason, that sort of logic we would do directly on each clickable element.

"SDK produce native button but there is no 'disable/enable' feature implemented." When using Exponea.setAppInboxProvider I can see the option to enabled/disable via ButtonStyle (AppInboxStyle>ButtonStyle>enabled?), is there no chance that this is being modified for some reason after everything is fully loaded?

adam1929 commented 9 months ago

Hi @StuartPyper Sorry for misunderstand of mine "SDK produce native button but there is no 'disable/enable' feature implemented." -> I meant that there is no SDK internal logic that will disable button for any reason (such as empty app inbox or so).

I'm not aware of "being modified after everything is fully loaded" case. Yes, there is such a style option, but I believe that you are not using it. This is handled as optional boolean so if it is not written it is not applied to button.

Could you please ask support channel for help? My goal here is to provide some logs, if there is some info about it.

Thank you

a-change commented 9 months ago

Hi @adam1929, I'm also seeing the same AppInboxButton behaviour in my React Native app on iOS, when I use Exponea.setAppInboxProvider provider call. On Android it works fine with the same setup.

My logs are in verbose mode, but taps on the button don't produce any logs either in XCode or in Terminal. I can assign onTouchEnd functionto the button and it works correctly.

If I remove Exponea.setAppInboxProvider, then appInbox starts working fine on iOS. Here's the setAppInboxProvider call:


Exponea.setAppInboxProvider({
      appInboxButton: {
        textSize: '16sp',
        textWeight: 'bold',
      },
      detailView: { 
        title: {
          textColor: '#262626',
          textSize: '20sp',
        },
        content: {
          textColor: '#262626',
          textSize: '16sp',
        },
        button: {
          textSize: '16sp',
          textColor: '#262626',
          backgroundColor: '#ffd500',
          borderRadius: '10dp',
        },
      },
      listView: {
        list: {
          backgroundColor: 'white',
          item: {
            content: {
              textSize: '16sp',
              textColor: '#262626',
            },
          },
        },
      },
    });
adam1929 commented 8 months ago

Hi guys @StuartPyper and @a-change . I was able to simulate issue. Most important thing here is 'when' is app inbox provider set to SDK. If you set provider Exponea.setAppInboxProvider({}) after button is shown, click events are "ignored". Problem for iOS platform is, that instance of provider is registered as click-handler for that button; so if you replace provider with new one, the old one is thrown away so it is not handling button click anymore. Fix for this is to set provider before SDK init or (mainly) before button is placed into UI. Or if you put button into UI and you set provider later, please "recreate" button. We need to bring fix for that situation into native iOS SDK, only then to RN SDK. I hope that you'll be able to implement hot-fix I wrote. Thank you for patience.

xcibik00 commented 7 months ago

Hi @StuartPyper and @a-change - we already fix it in native iOS SDK 2.25.0 -> update to it will be includet in next RN version 1.7.0