apptentive / apptentive-react-native

Apptentive SDK module for React Native

Home Page:https://learn.apptentive.com/article-categories/react-native/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

when calling register sdk returns "Apptentive already initialized"

mtpjr88 opened this issue · comments

RCT_EXPORT_METHOD(
	register:(NSDictionary *)configurationDictionary
	resolver:(RCTPromiseResolveBlock)resolve
	rejecter:(RCTPromiseRejectBlock)rejecter
) {
	if (self.registered) {
		rejecter(kRejectCode, @"Apptentive is already initialised", nil);
		return;
	}

This will boolean will always return true since
apptentiveKey and apptentiveSignature are required fields for the js sdk ie docs:
https://learn.apptentive.com/knowledge-base/react-native-integration-reference/

    const configuration = new ApptentiveConfiguration(
      credentials.apptentiveKey,
      credentials.apptentiveSignature
    );
- (BOOL)isRegistered {
	return Apptentive.shared.apptentiveKey != nil && Apptentive.shared.apptentiveSignature != nil;
}

Hi @mtpjr88, thanks for reaching out. We'll take a closer look and get back to you with next steps.

Are you able to launch any Apptentive dialogs despite this?

Hi @mtpjr88. My team mentioned that it looks like you're registering Apptentive twice.

Can you see any way that that might be possible? Also, is this preventing any Apptentive Dialogs from displaying?

We haven't seen this before so would appreciate your feedback in order to make a recommendation. Thanks!

@CaseyApptentive
well the issue is that Apptentive.shared.apptentiveKey and Apptentive.shared.apptentiveSignature
are required fields in the javascript sdk

const configuration = new ApptentiveConfiguration(
      credentials.apptentiveKey,
      credentials.apptentiveSignature
    );

thus Apptentive.shared.apptentiveKey and Apptentive.shared.apptentiveSignature
will not come as nil
and will always throw "Apptentive already initialized";

Seems like this thread might be dead, but chiming in to report I'm getting the same issue reported here.

As a way to avoid seeing the warning message in the app and in any error tracking services, you can swalllow it this way:

export const registerApptentive = async () => {
  const configuration = new ApptentiveConfiguration(
    credentials.apptentiveKey,
    credentials.apptentiveSignature,
  );
  try {
    await Apptentive.register(configuration);
  } catch {
    // Do whatever or nothing at all
  }

But ideally the library shouldn't throw a warning for a method that's required to use it.