braze-inc / braze-unity-sdk

Public repo for the Braze Unity SDK
https://www.braze.com
Other
27 stars 18 forks source link

Deeplink with Push notification for Unity 2019.4 (android , iOS) not working #83

Open mudassar024 opened 3 years ago

mudassar024 commented 3 years ago

Braze Unity android deeplink in push notification issue: Deeplink was working fine in Unity 2018.4.26 with Braze Unity plugin 2.7.1 After updating Unity to 2019.4.22 with Braze Unity plugin 2.8.0, deeplink with push notification is not working. Receivenig notificaton data and deeplink uri in logs only if app is already open, but not if app is closed.

Braze Unity iOS deeplink in push notification issue: Deeplink with push notification was not working in Unity 2018.4.26 with Braze 2.7.1 After updating Unity to 2019.4.22 with Braze Unity plugin 2.8.0, deeplink with push notification is working for only those users who already registered there push token. Here is the detail: to get device token for Unity 2019.4.22

IEnumerator RequestUninstallToken()
{
    const AuthorizationOption AUTHORIZATION_OPTION = AuthorizationOption.Alert | AuthorizationOption.Badge;
    using (var req = new AuthorizationRequest(AUTHORIZATION_OPTION, true))
    {
        while (!req.IsFinished)
        {
            yield return null;
        }
        if (req.Granted && req.DeviceToken.IsNotNullNorEmpty())
        {
             Appboy.AppboyBinding.RegisterAppboyPushMessages(Encoding.UTF8.GetBytes(req.DeviceToken));
        }
    }
}

Braze says BadDeviceTokenwhen try to send notificaion. so no notification received.

But if we use Obsolete method

NotificationServices.RegisterForNotifications(NotificationType.Alert | NotificationType.Badge | NotificationType.Sound);
Appboy.AppboyBinding.RegisterAppboyPushMessages(UnityEngine.iOS.NotificationServices.deviceToken);

token register successfully and we are receiving push notification, but deeplink is not working in this case..

Next we remove this line NotificationServices.RegisterForNotifications(NotificationType.Alert | NotificationType.Badge | NotificationType.Sound); and build , now push notification is working deeplink.. (because braze has device token already)

but how we register device token without calling "NotificationServices.RegisterForNotifications" Without calling this "NotificationServices.RegisterForNotifications" NotificationServices.deviceToken return null so we can't register device.

Q1. deeplink with push notification for unity android is not working? Q2. How do we register correct device token with new Unity version 2019.4.22? Q3. Why deeplink is not working when "NotificationServices.RegisterForNotifications" is in the code to get device token with obsolete method?

Bucimis commented 3 years ago

Hi @mudassar024, there were no changes to deep linking or push registration behavior between Braze Unity SDK versions 2.7.1 and 2.8.0.

Do you need a way to send a String instead of a byte[] into RegisterAppboyPushMessages on iOS? AuthorizationRequest's documentation recommends sending the String type DeviceToken back to the server unmodified (see https://docs.unity3d.com/Packages/com.unity.mobile.notifications@1.1/api/Unity.Notifications.iOS.AuthorizationRequest.html) - wonder if that's causing any issues. Though again, that's not related to deep links and nothing has changed on the Braze end there or in our registration code for some time.

mudassar024 commented 3 years ago

Here is only one question. How we can get deeplink uri with parameters in Unity , sent from braze dashboard with notification.. (deeplinking is working fine with Appsflyer, because they have onAppOpenAttribution callback, where we can get link with paramters.. but in braze there is no such callback for notification deeplink...)

Bucimis commented 3 years ago

Hi @mudassar024, we don't currently offer a convenient way to read the push deep link from the Unity layer, but have added it to our roadmap. Currently, we'd recommend working around this by implementing ABKURLDelegate and AppboyNavigator on iOS and Android natively, respectively. Those methods will allow you to intercept all deep links flowing through Braze and take action based on them. Let us know if that works for you.