You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Megacool SDK推荐系统问题:receivedShareOpened与sentShareOpened未触发

Troubleshooting Megacool's receivedShareOpened/sentShareOpened Events Not Firing

Hey there, let's break down why those critical referral events aren't triggering for you—especially since the console is picking up referral data, which means the core tracking is working under the hood. Here are targeted fixes and checks to try:


1. Verify Listener Registration Timing & Scope

  • Make sure Megacool.start() is called as early as possible in your MainActivity's onCreate() method—preferably before setContentView(). If you delay initialization (e.g., in an async task or after UI setup), the event might fire before your listener is registered.
  • Confirm your MainActivity is the app's launcher activity. If users open the app via a referral link that routes to a different activity, your listener won't catch the event unless you register it there too (or initialize Megacool in a base activity that all entry points inherit from).

2. Validate isFirstSession() Logic

  • Remember: isFirstSession() only triggers if the receiver (device B) opens the app for the first time ever after installation. If you tested opening the app on device B before clicking the referral link, this check will fail. Try a clean test:
    1. Uninstall the app from device B entirely.
    2. Install only via the referral link.
    3. Open the app immediately—this should trigger the event.
  • Avoid calling Megacool.getInstance().resetIdentity() repeatedly unless absolutely necessary, as it can disrupt session tracking.

3. Fix ProGuard/R8 Obfuscation Issues

If you're using code obfuscation, Megacool's event classes and listeners might be mangled, breaking callbacks. Add these rules to your proguard-rules.pro:

-keep class co.megacool.megacool.** { *; }
-keep class co.megacool.** { *; }
-keepattributes *Annotation*

Double-check that these rules apply to both debug and release builds—sometimes debug builds skip obfuscation, hiding the issue until you test a release variant.

4. Manually Refresh Pending Events

On device B, immediately after opening the app via the referral link, add this line to force Megacool to check for pending share events:

Megacool.getInstance().refresh();

This can trigger missed callbacks if the initial event check ran before your listener was ready.

5. Update to the Latest SDK Version

Older Megacool SDK versions have known bugs with event triggering. Update your Gradle dependency to the latest version (replace x.y.z with the current release number):

implementation 'co.megacool.megacool-android:megacool:x.y.z'

6. Double-Check API Key & Configuration

  • Confirm the API key in getString(R.string.megacool_api_key) matches exactly what's in your Megacool console—even a single typo or hidden whitespace can break event callbacks (while still allowing basic data to reach the console).
  • Scan your MegacoolConfig setup for accidental flags like disableEventTracking() that might be blocking callback triggers.

If none of these work, add debug logs to check for pending shares:

Log.d(TAG, "Pending shares: " + Megacool.getInstance().getPendingShares());
Log.d(TAG, "Current user ID: " + Megacool.getInstance().getCurrentUser().getUserId());

This will help you confirm if Megacool detects the referral share at all, even if the callback isn't firing.

内容的提问来源于stack exchange,提问作者Adam Varhegyi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 14:57:45