Smartech

Customer Engagement

For Android SDK

If you are building your Android app, follow the Android Customer Engagement steps for integration steps for push notifications & in-app messages.

For iOS SDK

If you are building your iOS app, follow the iOS Customer Engagement steps for integration steps for push notifications & in-app messages.

Handling deeplinks

To implement the deeplink in the iOS React Native app, please implement the following steps:

1. Create smtDeeplinkData Dictionary in appdelegate

@interface AppDelegate () <UNUserNotificationCenterDelegate, SmartechDelegate> {
     NSMutableDictionary *smtDeeplinkData;
}
var smtDeeplinkData = [String: Any]()

2. Initialize the dictionary and add observer in didFinishLaunchingWithOptions

smtDeeplinkData = [[NSMutableDictionary alloc] init];
 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotificationInTerminatedSate:) name:@"OnloadEvent" object:nil];
smtDeeplinkData = [:]

NotificationCenter.default.addObserver(self, selector: #selector(handleNotificationinTerminatedSate(notification:)), name: NSNotification.Name("OnloadEvent"), object: nil)

3. Add Smartech Deeplink Delegate methods

#pragma mark Smartech Deeplink Delegate

- (void)handleDeeplinkActionWithURLString:(NSString *)deeplinkURLString andCustomPayload:(NSDictionary *_Nullable)customPayload {
  
  NSMutableDictionary *smtData = [[NSMutableDictionary alloc] init];
  smtData[kSMTDeeplinkIdentifier] = deeplinkURLString ? deeplinkURLString : @"";
  smtData[kSMTCustomPayloadIdentifier] = customPayload ? customPayload : @{};
  smtDeeplinkData = smtData;
  [[NSNotificationCenter defaultCenter] postNotificationName:kSMTDeeplinkNotificationIdentifier object:nil userInfo:smtData];
}

- (void)handleNotificationInTerminatedSate:(NSNotification *)notification {
  if (smtDeeplinkData.count > 0) {
    [self handleDeeplinkActionWithURLString:smtDeeplinkData[kSMTDeeplinkIdentifier] andCustomPayload:smtDeeplinkData[kSMTCustomPayloadIdentifier]];
    smtDeeplinkData = [[NSMutableDictionary alloc] init];
  }
}
@objc func handleNotificationinTerminatedSate(notification: NSNotification) {
  if (smtDeeplinkData.count > 0) {
    self.handleDeeplinkAction(withURLString: smtDeeplinkData[kSMTDeeplinkIdentifier] as! String, andCustomPayload: smtDeeplinkData[kSMTCustomPayloadIdentifier] as? [AnyHashable : Any])
    smtDeeplinkData = [:]
  }
}

4. Add NotificationManager. It will create Bridge between React Native to native.

//NotificationManager.h file
#import <Foundation/Foundation.h>
#import <React/RCTBridgeModule.h>

NS_ASSUME_NONNULL_BEGIN

@interface NotificationManager : NSObject <RCTBridgeModule>

@end

NS_ASSUME_NONNULL_END

 

//NotificationManager.m file
#import "NotificationManager.h"

@implementation NotificationManager

RCT_EXPORT_MODULE()

RCT_EXPORT_METHOD(postNotification:(NSString *)name) {
  [[NSNotificationCenter defaultCenter] postNotificationName:name object:nil userInfo:nil];
}

@end

Updated about 4 hours ago


Customer Engagement


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.