Migration from Old to New SDK (React)

Migration from Old to New SDK (React)

React Native Version:

0.3.1 without geofence with Huawei
0.3.2 without geofence with Huawei
0.3.3 with geofence with Huawei
0.3.4 with geofence without Huawei

FOR IOS:

1.  Replace current pods with

Without geofence:

 pod 'Dengage', :git => 'https://github.com/dengage-tech/dengage-ios-sdk.git', :branch => 'version/5.1.1'


With geofence:

pod 'Dengage', :git => 'https://github.com/dengage-tech/dengage-ios-sdk.git', :branch => 'version/5.1.2'
Replace

 [coordinator setupDengage:@"BWUdMrMrI3YqDvJx_p_l_kkev8JcCFSHM5rkRCpwQdnvEWvMaRp7n_s_l_5olQe0RW_p_l_mI8BtHeFvsOBEYqR_s_l_YeZK6Cfr2DyN9nVJi2faUgyGgYdoeRHALe_p_l_ROuJxm0V5eBFKdZg9H7ULjDr4tU2Q0VJsgzqaRQ_e_q__e_q_" launchOptions:launchOptions application:application];
 
 
With
Without geofence
[coordinator setupDengage:@"BWUdMrMrI3YqDvJx_p_l_kkev8JcCFSHM5rkRCpwQdnvEWvMaRp7n_s_l_5olQe0RW_p_l_mI8BtHeFvsOBEYqR_s_l_YeZK6Cfr2DyN9nVJi2faUgyGgYdoeRHALe_p_l_ROuJxm0V5eBFKdZg9H7ULjDr4tU2Q0VJsgzqaRQ_e_q__e_q_" launchOptions:launchOptions application:application askNotificaionPermission:true];

With geofence 

OBJECTIVE C
[coordinator setupDengage:@"BWUdMrMrI3YqDvJx_p_l_kkev8JcCFSHM5rkRCpwQdnvEWvMaRp7n_s_l_5olQe0RW_p_l_mI8BtHeFvsOBEYqR_s_l_YeZK6Cfr2DyN9nVJi2faUgyGgYdoeRHALe_p_l_ROuJxm0V5eBFKdZg9H7ULjDr4tU2Q0VJsgzqaRQ_e_q__e_q_" launchOptions:launchOptions application:application askNotificaionPermission:true enableGeoFence:true];
 
SWIFT
 
With geofence
   coordinator.setupDengage(key: "4vPb6ldynxkMe5_p_l_j5mk_s_l_Mzf5IDjqoARjx_s_l_KQEBB1iw6c2EDnH7bz6QTIHsdGSCkeJP2kO7ZSD_s_l_PDTkB6jyG8ebacnSdRsenDLujyQwFZTxQNOUiiGgoLCoEJ_s_l_NhkNVg2UQOFMZPpAXr6P_p_l_R6PXBujw_e_q__e_q_", enableGeoFence : true,launchOptions: launchOptions as NSDictionary?, application: application);
 
 
Without  geofence
   coordinator.setupDengage(key: "integration key_", launchOptions: launchOptions as NSDictionary?, application: application);
 
 

ADD below line in didFinishLaunchingWithOptions

OBJECTIVE C

 UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
  center.delegate = self;
 
SWIFT
      UNUserNotificationCenter.current().delegate = self

ADD 2 New Functions

OBJECTIVE C
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
 
  completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge);
 
 
}
 
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler
{
  DengageRNCoordinator *coordinator = [DengageRNCoordinator staticInstance];
  [coordinator didReceivePush:center response:response withCompletionHandler:completionHandler];
 
}
 


SWIFT

 override func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
        let coordinator = DengageCoordinator.staticInstance;
        coordinator.didReceivePush(center, response, withCompletionHandler: completionHandler)
        
    }
    
    override func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
        completionHandler([.alert, .sound, .badge])
        
    }



For Android:
​
'com.github.dengage-tech:dengage-android-sdk:x.y.z


Change dependency to 5.6.1 for non geofence
5.6.2 without huawei and geofence
5.6.3 with geofence with huawei
5.6.4 with geofence without huwaei


REPLACE Service in manifest :

com.dengage.sdk.FcmMessagingService
com.dengage.sdk.HmsMessagingService



To

com.dengage.sdk.push.FcmMessagingService
com.dengage.sdk.push.HmsMessagingService

  If they have registered any receiver for carousel then

Change their carousel structure to this

import com.dengage.sdk.domain.push.model.CarouselItem
import com.dengage.sdk.domain.push.model.Message
import com.dengage.sdk.push.NotificationReceiver

class PushNotificationReceiver : NotificationReceiver() {

   override fun onCarouselRender(
       context: Context,
       intent: Intent,
       message: Message,
       leftCarouselItem: CarouselItem,
       currentCarouselItem: CarouselItem,
       rightCarouselItem: CarouselItem
   ) {
       super.onCarouselRender(
           context,
           intent,
           message,
           leftCarouselItem,
           currentCarouselItem,
           rightCarouselItem
       )

       val itemTitle = currentCarouselItem.title
       val itemDesc = currentCarouselItem.description

       // set intents (right button, left button, item click)
       val itemIntent = getItemClickIntent(intent.extras, context.packageName)
       val leftIntent = getLeftItemIntent(intent.extras, context.packageName)
       val rightIntent = getRightItemIntent(intent.extras, context.packageName)
       val deleteIntent = getDeleteIntent(intent.extras, context.packageName)
       val contentIntent = getContentIntent(intent.extras, context.packageName)

       val carouseItemIntent = getPendingIntent(context, 0, itemIntent)
       val carouselLeftIntent = getPendingIntent(context, 1, leftIntent)
       val carouselRightIntent = getPendingIntent(context, 2, rightIntent)
       val deletePendingIntent = getPendingIntent(context, 4, deleteIntent)
       val contentPendingIntent = getPendingIntent(context, 5, contentIntent)

       // set views for the layout
       val collapsedView = RemoteViews(
           context.packageName,
           R.layout.den_carousel_collapsed
       )
       collapsedView.setTextViewText(R.id.den_carousel_title, message.title)
       collapsedView.setTextViewText(R.id.den_carousel_message, message.message)

       val carouselView = RemoteViews(
           context.packageName,
           R.layout.den_carousel_portrait
       )
       carouselView.setTextViewText(R.id.den_carousel_title, message.title)
       carouselView.setTextViewText(R.id.den_carousel_message, message.message)
       carouselView.setTextViewText(R.id.den_carousel_item_title, itemTitle)
       carouselView.setTextViewText(R.id.den_carousel_item_description, itemDesc)

       carouselView.setOnClickPendingIntent(R.id.den_carousel_left_arrow, carouselLeftIntent)
       carouselView.setOnClickPendingIntent(
           R.id.den_carousel_portrait_current_image,
           carouseItemIntent
       )
       carouselView.setOnClickPendingIntent(R.id.den_carousel_item_title, carouseItemIntent)
       carouselView.setOnClickPendingIntent(R.id.den_carousel_item_description, carouseItemIntent)
       carouselView.setOnClickPendingIntent(R.id.den_carousel_right_arrow, carouselRightIntent)

       val channelId = createNotificationChannel(context, message)

       loadCarouselImageToView(
           carouselView = carouselView,
           imageViewId = R.id.den_carousel_portrait_left_image,
           carouselItem = leftCarouselItem,
           onComplete = {
               // you can call notificationManager.notify for devices that could not show carousel image contents
           }
       )

       loadCarouselImageToView(
           carouselView = carouselView,
           imageViewId = R.id.den_carousel_portrait_current_image,
           carouselItem = currentCarouselItem,
           onComplete = {
               // you can call notificationManager.notify for devices that could not show carousel image contents
           }
       )

       loadCarouselImageToView(
           carouselView = carouselView,
           imageViewId = R.id.den_carousel_portrait_right_image,
           carouselItem = rightCarouselItem,
           onComplete = {
               // you can call notificationManager.notify for devices that could not show carousel image contents
           }
       )

       val notification = NotificationCompat.Builder(context, channelId)
           .setSmallIcon(R.mipmap.ic_launcher)
           .setCustomContentView(collapsedView)
           .setCustomBigContentView(carouselView)
           .setContentIntent(contentPendingIntent)
           .setDeleteIntent(deletePendingIntent)
           .build()

       // show message again silently with next, previous and current item.
       notification.flags = Notification.FLAG_AUTO_CANCEL or Notification.FLAG_ONLY_ALERT_ONCE

       // show message
       val notificationManager = NotificationManagerCompat.from(context)
       notificationManager.notify(
           message.messageSource,
           message.messageId,
           notification
       )
   }



    • Related Articles

    • Migration from Old to New SDK (Flutter)

      Flutter versions 0.3.3 without geofence with huawei 0.3.4 without geofence without huawei 0.3.5 with geofence with huawei 0.3.6 with geofence without huawei FOR IOS: 1.  Replace current pods with  pod 'Dengage', :git => ...
    • Migration from Old to New SDK (iOS & Android) - Native

      FOR IOS: 1.  Replace current pods with pod 'Dengage', '~> 5.1.1.1' Replace         setupDengage(with: launchOptions) With         setupDengage(with: launchOptions, application: application) 2. func application( _ application: UIApplication, ...
    • Where can I see latest SDK version?

      The following link provides where the documentation is available for the SDK version. You can use the following links relevant to the technologies to see the required SDK version. IOS SDK Android SDK Huawei SDK React Native Cordova Flutter
    • How can I create a new user?

      To create a new user, invite the user in the following way: Click on settings and go to Users. Add new user. Provide the credentials & invite that user. An invitation will be sent to the user's email to access the system.
    • What's New

      Here's What's New in dEngage RECENT RELEASES June 05, 2020 New Features Available with this Release: Importing and Using Data from Amazon Redshift and Google Big Query Sending Push Notifications to Huawei Devices Using Reply-To Address in Email We're ...