braze-inc / braze-react-native-sdk

Public repo for the Braze React Native SDK
https://www.braze.com
Other
64 stars 83 forks source link

Content Card Modal doesn't close on pressing deep link #105

Closed owaiswarsi-aym closed 1 year ago

owaiswarsi-aym commented 3 years ago

Can anyone help, Is there any way to close the Content Card Modal on the pressing Card.

hokstuff commented 1 year ago

Hi @owaiswarsi-aym,

Are you still experiencing this issue? Can you provide more details around what Content Card Modal you are referring to?

For a quicker response, please reach out to support@braze.com with the campaign you are testing with as well as steps to repro in your app.

Thanks!

hokstuff commented 1 year ago

I'm closing out this thread due to inactivity and possible staleness. Feel free to reach out to support@braze.com if you still have concerns - thanks!

Yawanseh commented 1 year ago

I'm facing the same issue.

When I use Braze.launchContentCards(), and input a deep link into the Deep Link Into App card, it does direct me to the intended screen. However, the popup modal remains open and doesn't automatically close.

How can I fix this?

@hokstuff

Version

"react-native-appboy-sdk": "^1.41.0"

Preview

https://github.com/braze-inc/braze-react-native-sdk/assets/14093197/b9d5461c-536b-4b5b-b2f0-6b5698eb710c

hokstuff commented 1 year ago

Hi @owaiswarsi-aym,

Can you update to the latest version of the Braze React Native SDK and see if you are still experiencing that issue? Version 1.41.0 uses the legacy AppboyKit (ObjC) SDK, which contained some custom logic to determine where to present a new ViewController / popup modal. Versions 2.0.0+ use the Braze Swift SDK which removes custom logic like that.

For more catered support, please contact support@braze.com with the details above so that we can dive deeper into the issue on a separate thread instead of the current one.

Thanks!

Best, Daniel

Yawanseh commented 1 year ago

Hi @hokstuff, is there a way without migrating to the new SDK, as it requires React Native version 0.68 or higher.

hokstuff commented 1 year ago

Hi @Yawanseh,

The legacy AppboyKit SDK is no longer in active development, so there isn't anything we could do on our end to address the issue while using that SDK. You can review your app's integration to make sure there aren't any bugs or choose to use a custom UI instead of the default ones. Outside of that, you can explore using a workaround like the one mentioned here which allowed them to build on React Native 0.67.5 - though this is not officially supported by Braze.

Thanks!

luisfelipeas5 commented 3 months ago

The same thing happens with me. Using "@braze/react-native-sdk": "^11.0.0".

https://github.com/user-attachments/assets/f4ee7772-f2f6-42d0-8d28-d7b736d5fbca

hokstuff commented 3 months ago

Hi @luisfelipeas5,

Please contact support@braze.com so we can look into and debug your issue more effectively. In your thread, also include verbose logs when you are able to reproduce this issue along with any other relevant information for your integration (e.g. custom UI code if you are using it, any relevant delegates, etc).

Thanks!

iurichiba commented 3 months ago

EDIT: no need to use this workaround, it's been fixed: https://github.com/braze-inc/braze-react-native-sdk/issues/261#issuecomment-2307293580

Hey guys, in case anyone ends up here and still has problems with this, you can create a React Native bridge for iOS native code and dismiss it. Not ideal, but if support takes too long and you're in a rush, it might work for a while -- just make sure it's a temporary workaround and replace it with a definitive solution later, because it might always end up breaking for one reason or another.

import Foundation
import UIKit

@objc(BrazeNativeBridge)
class BrazeNativeBridge: NSObject {

  // MARK: - React Native Bridge
  // This is being used to dismiss Content Cards feed from the UI

  // MARK: Module Setup
  @objc
  static func requiresMainQueueSetup() -> Bool {
    return true // using the main thread for `dismissContentCardsModal`
  }

  // MARK: Helper Properties
  private let BRZFeedClass: AnyClass? = {
    // This class isn't visible, since it's not being exposed by the Pod
    let BRZFeedClassName = "BRZContentCardUIModalViewController"
    return NSClassFromString(BRZFeedClassName)
  }()

  // MARK: Exposed Functions
  @objc
  func dismissContentCardsModal() {
    DispatchQueue.main.async {
      guard
        let targetClass = self.BRZFeedClass,
        // keyWindow is deprecated, but that's what braze-react-native-sdk uses
        let keyWindow = UIApplication.shared.keyWindow,
        let rootVC = keyWindow.rootViewController,
        let presentedVC = rootVC.presentedViewController
      else {
        return
      }

      if presentedVC.isKind(of: targetClass) {
        rootVC.dismiss(animated: true)
      }
    }
  }

}