android - Google CampaignTrackingReceiver working partially -
i have implemented custom campaigntrackingreceiver in application code same mentioned below:
public class referrercatcher extends wakefulbroadcastreceiver { @override public void onreceive(context context, intent intent) { try { //starting referralintentservice further act on utm source componentname comp = new componentname(context.getpackagename(), referralintentservice.class.getname()); startwakefulservice(context, (intent.setcomponent(comp))); new campaigntrackingreceiver().onreceive(context, intent); } catch (exception e) { } } } and save utm_source in referralintentservice mentioned below:
public class referralintentservice extends intentservice { private string referrer; private context context; public referralintentservice() { super("referralintentservice"); } @override protected void onhandleintent(intent intent) { try { bundle extras = intent.getextras(); this.context = this; if (extras != null) { referrer = extras.getstring("referrer"); if (referrer.contains("%26")) { string array[] = referrer.split("%26"); sharedpreferences sharedpreferences = preferencemanager.getdefaultsharedpreferences(context); sharedpreferences.editor editor = sharedpreferences.edit(); editor.putstring(constants.utm_source, array[0].split("%3d")[1]); editor.commit(); } else { string array[] = referrer.split("&"); sharedpreferences sharedpreferences = preferencemanager.getdefaultsharedpreferences(context); sharedpreferences.editor editor = sharedpreferences.edit(); editor.putstring(constants.utm_source, array[0].split("=")[1]); editor.commit(); } // release wake lock provided wakefulbroadcastreceiver. referrercatcher.completewakefulintent(intent); } } catch (exception e) { crashlytics.logexception(e); } } my manifest both of these looks this:
<receiver android:name=".broadcastreciever.referrercatcher" android:enabled="true"> <intent-filter android:priority="2147483647"> <action android:name="com.android.vending.install_referrer" /> </intent-filter> </receiver> <service android:name=".services.referralintentservice" android:exported="false" /> i have tested same using following adb command , working desired:
adb shell broadcast -a com.android.vending.install_referrer -n "package_name/receiver" --es referrer "tracking_id=123456789" now strange thing in realtime working around 20% of users , in other cases not hit @ all.
the source of download of app google play.
kindly understand gap , provide solution if has faced same problem.
thanks time , help.
Comments
Post a Comment