adobe / aepsdk-react-native

A wrapper around the iOS and Android AEP mobile SDK to allow for integration with React Native applications.
Apache License 2.0
15 stars 28 forks source link

React native getExperienceCloudId returns time out error. #270

Closed bgrajesh57 closed 3 weeks ago

bgrajesh57 commented 1 year ago

getExperienceCloudId returning "time out error" form React native.

Adobe React native setup done based on the documentation. Please Let me know any library and configuration is missing.

React Native :

"dependencies": {
    "@adobe/react-native-aepcore": "^2.0.0",
    "@adobe/react-native-aepedge": "^2.0.0",
    "@adobe/react-native-aepedgeidentity": "^2.0.0",
    "@adobe/react-native-aepedgeconsent": "^2.0.0",
}

iOS:

import AEPCore
import AEPSignal
import AEPServices
import AEPLifecycle
import AEPIdentity
import AEPAssurance
import AEPAnalytics
import AEPUserProfile

 MobileCore.setLogLevel(.debug)
     let adobeAppID = Bundle.main.object(forInfoDictionaryKey: "Adobe_D") as! String
     let appState = application.applicationState
     MobileCore.registerExtensions([ Assurance.self,
                                     Analytics.self,
                                     UserProfile.self,
                                     Signal.self,
                                     Lifecycle.self,
                                     Identity.self,
                                   ], {
       MobileCore.configureWith(appId: adobeAppID)
       if appState != .background { MobileCore.lifecycleStart(additionalContextData:
       ["contextDataKey": "contextDataVal"]) }
         })

Android:

import com.adobe.marketing.mobile.AdobeCallback;
import com.adobe.marketing.mobile.Analytics;
import com.adobe.marketing.mobile.Assurance;
import com.adobe.marketing.mobile.Identity;
import com.adobe.marketing.mobile.InvalidInitException;
import com.adobe.marketing.mobile.Lifecycle;
import com.adobe.marketing.mobile.LoggingMode;
import com.adobe.marketing.mobile.MobileCore;
import com.adobe.marketing.mobile.Signal;
import com.adobe.marketing.mobile.UserProfile;

 MobileCore.setApplication(this);
         MobileCore.setLogLevel(LoggingMode.DEBUG);
         try {
             Assurance.registerExtension();
             Analytics.registerExtension();
             UserProfile.registerExtension();
             Identity.registerExtension();
             Lifecycle.registerExtension();
             Signal.registerExtension();

             MobileCore.configureWithAppID(getString('adobe_ID'));
             MobileCore.start(new AdobeCallback() {
                 @Override
                 public void call(Object o) {
                     MobileCore.lifecycleStart(null);
                 }
             });
         } catch (InvalidInitException e) {

         }

Expected Behaviour

getExperienceCloudId API should return value.

import {Identity} from '@adobe/react-native-aepedgeidentity';

  Identity.getExperienceCloudId()
    .then(cloudId => console.log('experience Cloud id: ' + cloudId))
    .catch(error => console.log('experience cloud id Error: ' + error));
};

Ex: Expected value
52612667349873636375709475823783369529

Actual Behaviour

getExperienceCloudId API should return value.

import {Identity} from '@adobe/react-native-aepedgeidentity';

  Identity.getExperienceCloudId()
    .then(cloudId => console.log('experience Cloud id: ' + cloudId))
    .catch(error => console.log('experience cloud id Error: ' + error));
};

Error:
getExperienceCloudId call timed out

Reproduce Scenario (including but not limited to)

Steps to Reproduce

Call Identity.getExperienceCloudId() function on react native App.

Platform and Version

iOS Android

Sample Code that illustrates the problem

import {Identity} from '@adobe/react-native-aepedgeidentity';

 Identity.getExperienceCloudId()
    .then(cloudId => console.log('experience Cloud id: ' + cloudId))
    .catch(error => console.log('experience cloud id Error: ' + error));
};

Looking forward to hear form you ASAP. Thanks.

cacheung commented 1 year ago

@bgrajesh57 In your react native code, you import the Identity library from @adobe/react-native-aepedgeidentity (Identity for Edge Network)

In your android and iOS native code, you registered with import com.adobe.marketing.mobile.Identity (which is the identity for Experience Cloud ID Service)

They are two different identities libraries.

From your native code registration info, it seems like you are sending data to the solutions directly, not going through edge network. In this case, in your react native, you need to remove import {Identity} from '@adobe/react-native-aepedgeidentity';

And import {Identity} from '@adobe/react-native-aepcore';

Identity.getExperienceCloudId() .then(cloudId => console.log('experience Cloud id: ' + cloudId)) .catch(error => console.log('experience cloud id Error: ' + error)); };

cacheung commented 1 year ago

Another thing, in your native code you have registered Assurance, Analytics. How did you get these extensions? I don't think you install them from react native dependencies, right?

Looking at your Android and iOS native registration code, it doesn't seem like you are using any aepedge libraries, however, you have them installed in react native dependencies.

What features you are trying to use?

bgrajesh57 commented 1 year ago

@cacheung Thanks for the clarification 👍

When I import Identity from @adobe/react-native-aepcore I can see the Experience cloud id for iOS. For Android still I can see time out error. Please assist me on this.

Android Error:

import {Identity, MobileCore, PrivacyStatus} from '@adobe/react-native-aepcore';

 Identity.getExperienceCloudId()
    .then(cloudId => console.log('experience Cloud id: ' + cloudId))
    .catch(error => console.log('experience cloud id Error: ' + error));

Error: getExperienceCloudId returned an unexpected error: general.callback.timeout
bgrajesh57 commented 1 year ago

@cacheung We want to track analytics for the app. We want to use below methods.

MobileCore.trackState,
MobileCore.trackAction

In that we don't need for below dependency lib for React native? Please confirm , But in the documentation mentioned below lib required to install.

 "@adobe/react-native-aepedge": "^2.0.0",
 "@adobe/react-native-aepedgeidentity": "^2.0.0",
 "@adobe/react-native-aepedgeconsent": "^2.0.0",
cacheung commented 1 year ago

Which documentation you are referring to? For using AEP-prefix mobile sdk and sending data to Analytics, please take a look of this faq.

In your native code, you have for Android

import com.adobe.marketing.mobile.Analytics;
Analytics.registerExtension();

How did you get the Analytics extension?

bgrajesh57 commented 1 year ago

Hi @cacheung Form Android registered import com.adobe.marketing.mobile.Analytics; and import com.adobe.marketing.mobile.MobileCore;

For you reference source below.


import com.adobe.marketing.mobile.AdobeCallback;
import com.adobe.marketing.mobile.Analytics;
import com.adobe.marketing.mobile.Assurance;
import com.adobe.marketing.mobile.Identity;
import com.adobe.marketing.mobile.InvalidInitException;
import com.adobe.marketing.mobile.Lifecycle;
import com.adobe.marketing.mobile.LoggingMode;
import com.adobe.marketing.mobile.MobileCore;
import com.adobe.marketing.mobile.Signal;
import com.adobe.marketing.mobile.UserProfile;

 MobileCore.setApplication(this);
         MobileCore.setLogLevel(LoggingMode.DEBUG);
         try {
             Assurance.registerExtension();
             Analytics.registerExtension();
             UserProfile.registerExtension();
             Identity.registerExtension();
             Lifecycle.registerExtension();
             Signal.registerExtension();

             MobileCore.configureWithAppID(getString('adobe_ID'));
             MobileCore.start(new AdobeCallback() {
                 @Override
                 public void call(Object o) {
                     MobileCore.lifecycleStart(null);
                 }
             });
         } catch (InvalidInitException e) {

         }

From React native to get the ECID getting below error. Pease let me know anything we missed out.

import {Identity, MobileCore, PrivacyStatus} from '@adobe/react-native-aepcore';

 Identity.getExperienceCloudId()
    .then(cloudId => console.log('experience Cloud id: ' + cloudId))
    .catch(error => console.log('experience cloud id Error: ' + error));

Error: getExperienceCloudId returned an unexpected error: general.callback.timeout
bgrajesh57 commented 1 year ago

@cacheung I can see the experienceCloudId form Android as well :)

bgrajesh57 commented 3 months ago

Hi,

We have update the latest adobe npm,

"@adobe/react-native-aepcore": "^6.0.0",
"@adobe/react-native-aepedge": "^6.0.0",
"@adobe/react-native-aepedgeidentity": "^6.0.0",
"@adobe/react-native-aepedgeconsent": "^6.0.0",

Now we can see below error again in Android alone, Please assist us.

Error: getExperienceCloudId returned an unexpected error: general.callback.timeout
addb commented 3 months ago

Hi @bgrajesh57,

Can you attach the logs for this. Is there a pattern, is it happening more on app first launches? If the configuration and extensions are correctly installed. You will need to add retry mechanism to getECID API i.e. if you get timeout error you can retry calling the getECID API. Limit the number of retries based on the tolerance of the app. Before that still need to check if timeout is solely due to processing like downloading configuration to check for privacy status and then responding with ECID.

cacheung commented 3 weeks ago

@bgrajesh57 Have you got this issue resolved?

bgrajesh57 commented 3 weeks ago

@cacheung its resolved , thanks