zoho / SalesIQ-Mobilisten-ReactNative

Your mobile app's ideal live chat partner. Power up your mobile App with the SalesIQ Mobilisten SDK for React-Native.
https://mobilisten.io/
9 stars 11 forks source link

[Expo] : ReferenceError: Can't find variable: Platform to import ZohoSalesIQ #80

Closed JoseEncinoza closed 4 months ago

JoseEncinoza commented 4 months ago

Hi! I'm currently having this error trying to import ZohoSalesIQ:

ReferenceError: Can't find variable: Platform

image

my Code :

import { ZohoSalesIQ } from 'react-native-zohosalesiq-mobilisten';

ZohoSales = {

    setKeys: async function () {

        let appKey = "...";
        let accessKey = "...";

        ZohoSalesIQ.initWithCallback(appKey, accessKey, (success) => {
            if (success) {
                ZohoSalesIQ.setLauncherVisibility(true);
            } else {
                console.log("Zoho Error: no se cargo chat")
            }
        });
    },

    openChat: async function () {
        console.log("Zoho: Abrimos Chat")
        ZohoSalesIQ.openChat();
    }
}
export default ZohoSales;

After a trace, the error occurs right at the import of ZohoSalesIQ:

import { ZohoSalesIQ } from 'react-native-zohosalesiq-mobilisten';

The message "ReferenceError: Can't find variable: Platform" refers to the file zohosalesiqJSWrapper.js in ./node_modules/react-native-zohosalesiq-mobilisten/components/. where it is using the following code in line 385:

if (Platform.OS === 'android') {
  Dimensions.addEventListener('change', ({ window: { width, height } }) => {
    RNZohoSalesIQ.refreshLauncherPropertiesForAndroid();
  });
}

But it fails to get the Platform from react-native as it is not being imported in this file. By importing Platform into this file. works correctly!!

const { NativeModules, Dimensions, Platform } = require('react-native');    //No I18N

but I guess should not make this changes at the node_modules level.

thanks :)

Node: v18.17.0 npm: 9.6.7 packages: "expo": "~50.0.5", "react-native": "0.73.4", "react-native-zohosalesiq-mobilisten": "^8.0.4",

bhahirathan-mb-11956 commented 4 months ago

Hi @JoseEncinoza ,

Thank you for your patience. We have fixed this issue.

We recommend you update to the latest version 8.0.5, and verify. Please feel free to write back to us at (support@zohosalesiq.com) in case of any issues.

Regards, Bhahirathan M Zoho SalesIQ.