Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InAppMessagingDisplayMessage shows incorrect type for imageOnly #8081

Closed
fumito-ito opened this issue May 14, 2021 · 4 comments · Fixed by #8118
Closed

InAppMessagingDisplayMessage shows incorrect type for imageOnly #8081

fumito-ito opened this issue May 14, 2021 · 4 comments · Fixed by #8118
Assignees
Labels
api: inappmessaging Firebase In App Messaging
Milestone

Comments

@fumito-ito
Copy link
Contributor

fumito-ito commented May 14, 2021

[REQUIRED] Step 1: Describe your environment

  • Xcode version: 12.4
  • Firebase SDK version: 7.3.0
  • Installation method: Carthage
  • Firebase Component: InAppMessaging

[REQUIRED] Step 2: Describe the problem

ImageOnly message shows incorrect message type. It may be a bug of parsing passing data.

Steps to reproduce:

  1. add new message as Image Only message at Firebase Console
  2. send test message
  3. open app with following code

Relevant Code:

class Sample: InAppMessagingDisplay {
    func displayMessage(_ messageForDisplay: InAppMessagingDisplayMessage, displayDelegate: InAppMessagingDisplayDelegate) {
        switch messageForDisplay.type {
        case .banner, .card:
            break
        case .modal:
            print("When set `imageOnly` message at firebase console, message will be received with `modal` type")
        case .imageOnly:
            print("This line will be never called.")
        @unknown default:
            break
        }
    }
}

// at AppDelegate
InAppMessaging.inAppMessaging().messageDisplayComponent = Sample()
@google-oss-bot
Copy link

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

@paulb777 paulb777 added api: inappmessaging Firebase In App Messaging and removed needs-triage labels May 14, 2021
@yakovmanshin
Copy link
Contributor

There’s this issue indeed. I’ve faced it myself, and I think I’ll look into it.

@fumito-ito As a quick fix, you can determine message type by type-casting the messageForDisplay instance, like that:

switch messageForDisplay {
    case let bannerMessage as InAppMessagingBannerDisplay:
        print(bannerMessage)
    case let cardMessage as InAppMessagingCardDisplay:
        print(cardMessage)
    case let imageOnlyMessage as InAppMessagingImageOnlyDisplay:
        print(imageOnlyMessage)
    case let modalMessage as InAppMessagingModalDisplay:
        print(modalMessage)
    default:
        break
}

In fact, that’s the way message type is determined in the original implementation of IAM.

@christibbs
Copy link
Contributor

This is a one-liner fix that will go out with the next release.

Bug is here.

@christibbs christibbs self-assigned this May 17, 2021
@christibbs
Copy link
Contributor

Thanks for the report @fumito-ito.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: inappmessaging Firebase In App Messaging
Projects
None yet
5 participants