Flurry Push не открывается глубокая связь - PullRequest
0 голосов
/ 03 июня 2019

Я пытаюсь отправить уведомление о глубоких связях, используя Flurry, вместо этого уведомление открывает приложение и не воспроизводит звук. Я использую для этого автоинтеграцию, и у меня есть класс MyFlurryMessagingListener, как он есть из документации Flurry.У меня нет ошибок, только эта проблема, и да, я обязательно выбрал «Глубокие ссылки» при создании Push In Flurry Dashboard.

Build Gradle

 implementation 'com.flurry.android:analytics:11.6.0@aar'
    implementation 'com.flurry.android:marketing:11.6.0@aar'
    implementation 'com.google.firebase:firebase-core:16.0.9'
    implementation 'com.google.firebase:firebase-messaging:18.0.0'

MyApplication Class

public class MyApplication extends Application {
    private static final String TAG = "MyApplication";
    @Override
    public void onCreate() {
        super.onCreate();

        String refreshedToken = FirebaseInstanceId.getInstance().getToken();
        Log.d(TAG, "REGISTERED TOKEN: " + refreshedToken);

        FlurryMarketingOptions flurryMessagingOptions = new FlurryMarketingOptions.Builder()
                .setupMessagingWithAutoIntegration()
                .withDefaultNotificationIconResourceId(R.drawable.ic_notification)
                .withDefaultNotificationIconAccentColor(getResources().getColor(R.color.colorPrimaryDark))
                .build();

        FlurryMarketingModule marketingModule = new FlurryMarketingModule(flurryMessagingOptions);

        new FlurryAgent.Builder()
                .withLogEnabled(true)
                .withModule(marketingModule)
                .build(this, "CCCCCTESTTESTTESTTEST");
    }

}

MyFlurryMessagingListener Class

public class MyFlurryMessagingListener implements FlurryMessagingListener {

    final static String LOG_TAG = MyFlurryMessagingListener.class.getCanonicalName();

    Context context;

    public MyFlurryMessagingListener(Context context) {

        this.context = context;

    }

    @Override

    public boolean onNotificationReceived(FlurryMessage flurryMessage) {

        // determine if you'd like to handle the received notification yourself or not

        boolean handled = false;

        // flurry will not show notification if app is in foreground, so handle it appropriately

        if (FlurryMessaging.isAppInForeground()) {

            // handle the notification using data from FlurryMessage

            // NOTE: since you are handling the notification, be sure to call logNotificationOpened and logNotificationCancelled after this

            handled = true;

        }

        return handled;

    }

    @Override

    public boolean onNotificationClicked(FlurryMessage flurryMessage) {

        // NOTE: THIS WILL ONLY BE CALLED IF FLURRY HANDLED onNotificationReceived callback

        // determine if you'd like to handle the clicked notification yourself or not

        boolean handled = false;



        return handled;

    }

    @Override

    public void onNotificationCancelled(FlurryMessage flurryMessage) {

        Log.d(LOG_TAG, "Notification cancelled!");

    }

    @Override

    public void onTokenRefresh(String refreshedToken) {

        Log.d(LOG_TAG, "Token refreshed - " + refreshedToken);

    }

    @Override

    public void onNonFlurryNotificationReceived(Object nonFlurryMessage) {

        // If Flurry receives a non-Flurry message, it will be passed to you here. You can cast the object

        // based on the push provider. For example...

        if (nonFlurryMessage instanceof RemoteMessage) {

            RemoteMessage firebaseMessage = (RemoteMessage) nonFlurryMessage;



        }

    }

}

1 Ответ

1 голос
/ 18 июня 2019

Чтобы использовать глубокую ссылку, вам необходимо выполнить дополнительные шаги интеграции, даже с автоинтеграцией.

  1. Настройте ваше приложение для использования глубоких ссылок:
<activity     
   android:name=".DeeplinkTestActivity">

   <intent-filter>
      <action android:name="android.intent.action.VIEW" />
      <category android:name="android.intent.category.DEFAULT" />
      <category android:name="android.intent.category.BROWSABLE" />

      <!-- This will open deeplinks structured like - "testapp://deeplink/example" -->

      <data

         android:scheme="testapp"
         android:host="deeplink"
         android:pathPrefix="/example" />

   </intent-filter>
</activity>
  1. В методе приложения onNotificationClicked извлеките вашу диплинк, включенный в push-уведомление с ключевым словом "deeplink"

@ Override

public boolean onNotificationClicked(FlurryMessage flurryMessage) {

    // NOTE: THIS METHOD WILL ONLY BE CALLED IF FLURRY HANDLED onNotificationReceived callback

    // determine if you'd like to handle the clicked notification yourself or not

    boolean handled = false;

    // see if notification contains deeplink

    if (flurryMessage.getAppData() != null && flurryMessage.getAppData().containsKey("deeplink")) {

        String deeplink = flurryMessage.getAppData().get("deeplink");

        // create the Intent

        final Intent deeplinkIntent = new Intent(Intent.ACTION_VIEW);

        deeplinkIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        deeplinkIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

        // set the data using your deeplink

        deeplinkIntent.setData(Uri.parse(deeplink));

        // add the FlurryMessage to extras

        FlurryMessaging.addFlurryMessageToIntentExtras(deeplinkIntent, flurryMessage);

        // make sure the deeplink resolves to an activity, then open it

        if (deeplinkIntent.resolveActivity(context.getPackageManager()) != null) {

            context.startActivity(deeplinkIntent);

            // tell flurry you've handled the notification

            handled = true;

        }

    }

    return handled;

}
...