Skip to content

Conversation

@shtomar-adb
Copy link
Contributor

  • Added Javascript API's in Messaging package to handle In app Messages.
  • Implementation in iOS native side of RN Messaging package to handle In app Message.
  • Updated sample app

Description

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

// @"onShow", @"onDismiss", @"shouldShowMessage",@"urlLoaded"
const eventEmitter = new NativeEventEmitter(RCTAEPMessaging);
eventListenerShow = eventEmitter.addListener('onShow', (event) => {
console.log(">>>>> onShow");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove these console logs and use SDK debug logs instead?

@@ -0,0 +1,54 @@
/*
Copyright 2021 Adobe. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2022

@@ -0,0 +1,29 @@
/*
Copyright 2021 Adobe. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2022

@yangyansong-adbe
Copy link
Contributor

@shtomar-adb can you add a private flag to messaging's package.json file? like ->


Then the (Lerna) publish script will ignore this private package. lerna/lerna#536 (comment)

Copy link
Member

@sbenedicadb sbenedicadb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good with a few questions. let me know when you make the changes we talked about on our call today and i'll re-review

NSLog(@">>>> shouldShowMessageWithMessage Message id: %@", messageObj.id);
[cachedMessages setObject:messageObj forKey:messageObj.id];
[self emitEventWithName:@"shouldShowMessage" body:@{@"id":messageObj.id, @"autoTrack":messageObj.autoTrack ? @"true" : @"false"}];
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add a comment here in code explaining why we're using the semaphore

}

RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(shouldShowMessage: (BOOL) shouldShowMessage) {
self->shouldShowMessage = shouldShowMessage;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any particular reason why you're using -> notation here instead of .?
e.g. - self.shouldShowMessage = shouldShowMessage;

Comment on lines 145 to 161
- (NSArray<NSString *> *) supportedEvents {
return @[@"onShow", @"onDismiss", @"shouldShowMessage",@"urlLoaded"];
}

- (void) startObserving {
hasListeners = true;
}

- (void) stopObserving {
hasListeners = false;
}

- (void) emitEventWithName: (NSString *) name body: (NSDictionary<NSString*, NSString*> *) dictionary {
if(hasListeners){
[self sendEventWithName:name body:dictionary];
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this section of functions to support the synchronous calls to and from javascript?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This functions are used to send events(along with event data) from native to JS event listeners.
The boolean hasListeners indicates that if an event Listener exists in the JS end. Then only send the event otherwise RN will give warning.

The events are used to notify the JS about the MessageDelegate functions called. Which further in JS are used to call corresponding Message Delegate functions registered in the JS.

```

**Podfile setup**
The In app Message APIs dependes on the AEP Messaging 1.1.0. This version is not yet published to the Cocoapods but is available in the public [github repository](https://github.com/adobe/aepsdk-messaging-ios/tree/staging). Add the following pod dependency in your applications Podfile under the application target.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: dependes -> depends

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AEPMessaging, v1.1.0

## Messaging SDK API usage
Messaging SDK APIs must be called from the native Android/iOS project of React Native app.
## Push Message API usage
Push Mesage related APIs in the Messaging SDK must be called from the native Android/iOS project of React Native app.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: Mesage > messaging

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so maybe phrase like Push messaging APIs in the SDK must be called...?


## In App Messages API reference
### refreshInAppMessages
Initiates a network call to retrieve remote In-App Message definitions.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In-App Message probably doesn't need to be capitalized here

```

### setMessagingDelegate
Sets the UI Message delegate to listen the Message lifecycle events.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sets the MessagingDelegate in AEPCore.

```

### saveMessage
Call to the saveMessage leads to in-memory caching of the Message object. Cached Message object can be later use to show message. This function should be called from **shouldShowMessage** of MessagingDelegate.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Natively caches the provided Message object.

message.setAutoTrack(true);
```
### clearMessage
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering if maybe we should change the name of this method to just clear?

message.clearMessage(); sounds a little redundant

message.clear(); sounds better

🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does sound better.

urlLoaded(url: string, message: Message): void;
};
```
Object of type MessagingDelegate can be create as shown below:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: create > created

Comment on lines 355 to 368
anotherWorkflowStatus = "complete";
currentMessage.show();
}

function shouldShowMessage(message: Message): boolean {
if(someOtherWorkflowStatus == "inProgress") {
// store the current message for later use
Messaging.saveMessage(message);
currentMessage = message;
return false
}

return true
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we're using different names for the same variable in the example:

anotherWorkflowStatus and someOtherWorkflowStatus

Copy link
Contributor

@cacheung cacheung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Readme, Android initializing example
Update
import com.adobe.marketing.mobile.edge.identity;
to
import com.adobe.marketing.mobile.edge.identity.Identity;

@leiteszeke
Copy link

Hi guys. Is there any plan on merging / including this in RN library?

Copy link
Member

@sbenedicadb sbenedicadb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a couple of small things that need to be updated. i'll merge those changes into the messaging branch.

AEPMobileAssurance.class] completion:^{
[AEPMobileCore lifecycleStart:@{@"contextDataKey": @"contextDataVal"}];
AEPMobileOptimize.class] completion:^{
[AEPMobileCore configureWithAppId:@"3149c49c3910/aaaac75639c6/launch-813b9d67d95e-development"];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'll make sure to revert this back to your-app-ID

@@ -0,0 +1,99 @@
/*
Copyright 2021 Adobe. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to change to 2022

#import "RCTAEPMessaging.h"
@import AEPMessaging;
@import AEPCore;
@import AEPServices;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can remove this since it's imported by the header

Copy link
Contributor

@yangyansong-adbe yangyansong-adbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, only a small fix is needed.

MobileCore.setApplication(this);
MobileCore.setLogLevel(LoggingMode.DEBUG);
try {
UserProfile.registerExtension();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add those extension registrations back.

@sbenedicadb sbenedicadb merged commit 5ad8b55 into staging Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants