braze-inc / braze-swift-sdk

Braze SDK for the Apple ecosystem, including: iOS, macOS, iPadOS, visionOS, tvOS
https://www.braze.com
Other
52 stars 19 forks source link

[Feature]: Alternative to AppBoyProvider.isAppboyRemoteNotification #66

Closed remarcus closed 1 year ago

remarcus commented 1 year ago

What problem are you facing?

Hey, we're migrating from Appboy to Swift SDK.

In userNotificationCenter(_:willPresent:withCompletionHandler:) we had check for AppBoyProvider.isAppboyRemoteNotification to provide required presentation options for foreground Braze push notifications.

I don't see alternative to this method and Braze.Notifications.isInternalNotification(userInfo:) returns false as this is not an internal push.

We handle our internal push notifications inside our app and show a custom UI, so now there's no way to differentiate.

Could you assist me with that?

Workarounds

-

Ideal Solution

No response

Other Information

No response

jerielng commented 1 year ago

Hey @remarcus, one thing to note is that isAppboyRemoteNotification is not equivalent to isInternalNotification in the Swift SDK. isAppboyInternalRemoteNotification in AppboyKit would be the equivalent to Braze.Notifications.isInternalNotification, so the behavior you observe may be different.

That being said, isAppboyRemoteNotification has been removed to simplify the Notifications interface. If you would like to continue checking if a notification is from Braze, you can check for the presence of a valid object with the key "ab" in the payload of notification.request.content.userInfo.

Alternatively, we have also provided some new ways using boolean return values to verify that a push was handled by Braze:

If you'd like to learn more about the implementation and usage of these methods, you can refer to our push integration tutorial here.

remarcus commented 1 year ago

Hey @jerielng,

Thanks for a quick response. I understand that the methods are not the same.

What would be the valid object definition for "ab"? That it contains object with "c" as a key and some UUID? Maybe checking for "ab" existence will be enough for us.

jerielng commented 1 year ago

Hi @remarcus, we have a sample implementation here in our BrazeKitCompat library. You should be able to replicate this same logic in your app.

Let us know if you have further questions about that!

remarcus commented 1 year ago

Thanks for the help! Closing the issue 😃