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

fix(braze): ensure braze has a scene #593

Merged
merged 3 commits into from
Apr 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions PocketKit/Sources/PocketKit/Notifications/PocketBraze.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ typealias BrazeProtocol = BrazeSDKProtocol & PushNotificationProtocol
Class that is managing our Braze SDK implementation
*/
class PocketBraze: NSObject {
/**
Our Braze SDK Object
*/

/// Our Braze SDK Object
let braze: Braze

init(apiKey: String, endpoint: String, groupdId: String) {
// Init Braze with our information.
var configuration = Braze.Configuration(
let configuration = Braze.Configuration(
apiKey: apiKey,
endpoint: endpoint
)
Expand Down Expand Up @@ -108,7 +107,22 @@ extension PocketBraze: BrazeInAppMessageUIDelegate {
_ ui: BrazeInAppMessageUI,
prepareWith context: inout BrazeInAppMessageUI.PresentationContext
) {
// Customize the in-app message presentation here using the context
// We need to set our scene for Braze because our UIKit + SwiftUI stuff does not seem to work with Braze's default
Copy link
Contributor

@cyndichin cyndichin Apr 12, 2023

Choose a reason for hiding this comment

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

Suggested change
// We need to set our scene for Braze because our UIKit + SwiftUI stuff does not seem to work with Braze's default
// We need to set our scene to show our local Braze in-app messaging because our UIKit + SwiftUI stuff does not seem to work with Braze's default

@cyndichin that stuff is in the comment, can you help me make it more clear? That code creates a local in app message.

Ohh okay, added suggestion for the comment. I was more curious to understand why we need this local message when it worked previously without this code (we can also discuss live in Unleash meeting).

Copy link
Member Author

Choose a reason for hiding this comment

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

@cyndichin that i can't answer, i dug through their sdk, and cant see why. But our codes been changing a lot. This is an area where im just accepting something changed, and this fixes it. 🤷‍♂️

Copy link
Contributor

Choose a reason for hiding this comment

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

okay! thanks for always clarifying for me! approved

// https://github.com/braze-inc/braze-swift-sdk/blob/d2ac02aad85418dd1b044bdaf7306b2e1d3e3822/Sources/BrazeUI/InAppMessageUI/InAppMessageUI.swift#L123-L127
// Note: that if we ever introduce multiple scenes (CarPlay) we will need to update this.
// Note: You can also test this code by putting the below code in the init function above.
// let modal: Braze.InAppMessage = .modal(
// .init(
// graphic: .icon("🙄"),
// header: "Header text",
// message: "Local modal in-app message"
// )
// )
//
// DispatchQueue.main.async {
// inAppMessageUI.present(message: modal)
// }
context.windowScene = (UIApplication.shared.connectedScenes.first as? UIWindowScene)
}

func inAppMessage(
Expand Down