Help adding Intercom SDK to the Flutter Shell

Hello @Luc_Zentar,

the problem I have is that when a user logs in to the Backendless app, I need to run JS code to pass the user ID to Intercom so the user can be identified and logged in to Intercom using the Intercom SDK.

If I understood you correctly, you can use the afterLogin event handler in the Cloud Code section for this purpose. This hook (event handler) will be called automatically by the Backendless after each successful login into Backendless, and there you’ll be able to run a request for login into a third-party service.

Best Regards,
Stanislaw

This doesn’t help as it doesn’t get the data passing between the Backendless code and the native SDKs in Flutter. With Intercom there is a requirement for the two to be able to pass data back and forth.

So for this case, the Intercom login wouldn’t be associated with the mobile phone user.

Hello, @Luc_Zentar.

There is a way to do this. I’ll give an example below of how it works:
For example I need login user in JS code, then I need to pass it into Flutter code. Perform some actions with it and return some answer back into JS. This is code in Codeless:

When you click on this button, flutter receives a request to execute the “your_custom_func” method, in order to process this request, I will add this code to the bridge_manager class(58-65 into switch block):

        case 'your_custom_func':
          {
            //something code
            //For example intercom api
            return buildResponse(
                data: requestContainer,
                response: 'Completed'); //maybe result of intercom api
          }

The buildRequest() method then returns the response to the JS code.

If you have any questions, please ask, I will gladly try to help you.

Best Regards, Nikita.

Thank you, I have this error when trying to run the execute native method:

sdk.js:14 Can not send a request to the native code, because the Device Provider is not configured

  1. {type: ‘IntercomLogin’, payload: ‘1D689771-90F2-4738-B349-272E79590215’}

  2. payload: “1D689771-90F2-4738-B349-272E79590215”

  3. type: “IntercomLogin”

  4. [[Prototype]]: Object

Is there any documentation or videos for how the native methods work? I haven’t been able to find anything

Hello, @Luc_Zentar.

Unfortunately, this is a new feature and is currently under development, so it has not yet been documented. So you can find out about the functionality of this feature only here :frowning:

Please provide the custom code or codeless blocks you are calling to build and send this request.

Best Regards, Nikita.

No problem! Just wanted to make sure I wasn’t asking questions here that could be answered by reading a document or watching a video :slight_smile:

App ID = 8518B92E-A6AA-5589-FFA0-B863E4A63F00
Container = frontEnd
Page = login

Hello, @Luc_Zentar.

Codeless logic looks like good. Can you please provide the flutter code that is responsible for processing this request?

Best Regards, Nikita.

I missed this nuance. The bridge is only available from the native app shell FOR MOBILE DEVICES. As far as I can tell, are you trying to run in a regular browser from a PC? It won’t work.

Hello @Nikita_Fedorishchev - that was my mistake, but I have now tested using Android Studio and it is still not working.

This is the code in the bridge_manager file

class BridgeManager {
static const String _OPERATION_REGISTER_DEVICE = ‘REGISTER_DEVICE’;
static const String _SOCIAL_LOGIN = ‘SOCIAL_LOGIN’;
static const String INTERCOM_LOGIN = ‘IntercomLogin’;

static Future executeRequest(Map data) async {
final requestContainer = RequestContainer(
data[‘payload’][‘id’], data[‘payload’][‘type’],
userToken: data[‘payload’][‘userToken’]);

try {
  var result;
  switch (requestContainer.operations) {
    case INTERCOM_LOGIN:
      {
        result =
        await BridgeUIBuilderFunctions.registerForPushNotifications();
        if (result == null) throw Exception('Cannot register device');
        return buildResponse(
          data: requestContainer,
          response: {
            'deviceToken': (result as DeviceRegistrationResult).deviceToken
          },
        );
      }

What error are you getting when testing from Android Studio?

There is no error, it just doesn’t execute and the login button seems to not be working.

I have checked the user table in the database, the login is successful as the last login date is updated.

@Nikita_Fedorishchev I can share the git repository with you if this helps so you can see all the code and view in Android Studio

I was able to reproduce your error and find a solution.
If you pass a whole user object, then everything works without problems. It looks like a bug, we will look into this problem.
Can you try?

Best Regards, Nikita.

Like this?

Yes, this solved the problem for me.

Did the problem go away?

I’m waiting for confirmation…will let you know

1 Like

Internal ticket created: BKNDLSS-28257

Hello, @Nikita_Fedorishchev Hope you are doing well. Would you please check the following video file? Login function does not work for now.

Hello, @Aleksandar_Vukovic.

The problem is codeless blocks, you made some mistake somewhere. Could you send the structure of your program to UI-Builder?

Best Regards, Nikita.