Android play market Referral understanding - android

I'm trying to add to my app a referral tracking system so I would be able to know who of my affiliates partner sent the user to download my program. I've encounter several websites who write about it but still failed to understand some issues.
I've added this to my menifest
<receiver android:name="com.cool.PlayStoreReferralReceiver" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
and created this object:
public class PlayStoreReferralReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
if (extras != null) {
String referrerString = extras.getString("referrer");
Log.d("DEBUG", "Set Value:"+referrerString);
}
}
}
It seems to be working fine but I have 2 questions
I dont understand why I need to build a link which look like that for example:
https://play.google.com/store/apps/details?id=com.joelapenna.foursquared&referrer=utm_source%3Dtooyoou%26utm_medium%3Dbanner%26utm_term%3Dfoursquare%26utm_content%3Dfoursquare-tooyoou%26utm_campaign%3Dfoursquare-android
and not do it my way like that:
https://play.google.com/store/apps/details?id=com.joelapenna.foursquared&referrer=affiliate1
I've been checking it with the program 'Referral Tester' and it seems to work is that safe enough to relay on ?
Thanks so much,
Or.

For those who need to know:
Referral Tester working great.
you can get the referral like that : https://play.google.com/store/apps/details?id=com.joelapenna.foursquared&referrer=affiliate1 or basicly anything after the referrer parameter

Related

Twitter app returns wrong value in onActivityResult

I'm composing a Tweet and then launch Twitter app to tweet it like that:
intent = new TweetComposer.Builder(getFragmentActivity())
.text(viewHolder.etShareText.getText().toString())
.url(contentUrl)
.image(imageUri)
.createIntent();
It worked for a long time, and it still works, I'm able to post a tweet to my profile, but some time ago every action was resulted with RESULT_CANCELED in my onActivityResult() method despite the actual result was successfull.
Maybe something had changed in Twitter API? How to handle results now?
Actually, in this case onActivityResult() usage may not true way. To catch composing result, like vijikumar said, we should use BroadcastReceiver. But this information is not enough for us. Because in many cases, twitter composing ways are confused with each other. Like documentation said ; there are two ways to compose tweets :
Launch the Twitter application’s Tweet Composer
Launch the Twitter Kit Native Composer
If you prefer to use first way, as long as i see, there is not a healthy method to catch composing result using BroadcastReceiver, onActivityResult or etc.
BroadcastReceiver method does not work using first way. But if you prefer to use second way, you can catch composing result using BroadcastReceiver in a healthy position. You shouldn't think that first way is not important. I am going to talk about first way briefly.
To do these above ;
Second Way
Add below repository and dependencies in your app level gradle file
repositories {
jcenter()
}
compile 'com.twitter.sdk.android:twitter-core:3.1.1'
compile 'com.twitter.sdk.android:tweet-composer:3.1.1'
Then add below BroadcastReceiver
public class MyResultReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
if (TweetUploadService.UPLOAD_SUCCESS.equals(intent.getAction())) {
// success
} else if (TweetUploadService.UPLOAD_FAILURE.equals(intent.getAction())) {
// failure
} else if (TweetUploadService.TWEET_COMPOSE_CANCEL.equals(intent.getAction())) {
// cancel
}
}
}
Then add your BroadcastReceiver to the application manifest file like below
<receiver
android:name=".MyResultReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.twitter.sdk.android.tweetcomposer.UPLOAD_SUCCESS"/>
<action android:name="com.twitter.sdk.android.tweetcomposer.UPLOAD_FAILURE"/>
<action android:name="com.twitter.sdk.android.tweetcomposer.TWEET_COMPOSE_CANCEL"/>
</intent-filter>
</receiver>
As last, to open the composer screen, start ComposerActivity using below code block
final TwitterSession session = TwitterCore.getInstance().getSessionManager()
.getActiveSession();
final Intent intent = new ComposerActivity.Builder(YourActivity.this)
.session(session)
.text("Love where you work")
.hashtags("#twitter")
.createIntent();
startActivity(intent);
When you use this way, you will catch composer result in BroadcastReceiver.
I will not share any code block about First Way. But why can we need the first way ? Actually first way contains very rich content but as long as i see, it does not support to catch result. So second way is enough for us in many cases. however if Twitter app does not exist the device, second way will crash because of session. In this case, we should use first way to open composer screen in internet browser. So we should use both ways but like you see that first one is more effective than second one.
NOTE : Do not forget to add the twitter kit initialization configurations and authentication mechanisms please.
Use BroadcastReceiver.
public class MyResultReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
if (TweetUploadService.UPLOAD_SUCCESS.equals(intent.getAction())) {
// success
final Long tweetId = intentExtras.getLong(TweetUploadService.EXTRA_TWEET_ID);
} else {
// failure
final Intent retryIntent = intentExtras.getParcelable(TweetUploadService.EXTRA_RETRY_INTENT);
}
}
}
In manifest
<receiver
android:name=".MyResultReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.twitter.sdk.android.tweetcomposer.UPLOAD_SUCCESS"/>
<action android:name="com.twitter.sdk.android.tweetcomposer.UPLOAD_FAILURE"/>
</intent-filter>
</receiver>

How to override the behavior of opening Appboy web activity in deeplink In App messge

I am facing a problem in override the On Click Behavior in Appboy deeplink
Please find the following data
1- Register Appboy in BaseActivity which is the parent activity for all Application Activities
#Override
protected void onResume() {
AppboyInAppMessageManager.getInstance().registerInAppMessageManager(this);
Appboy.getInstance(this).requestInAppMessageRefresh();
}
#Override
protected void onPause() {
AppboyInAppMessageManager.getInstance().unregisterInAppMessageManager(this);
}
2- Add the receivers in Manifest File as following
<receiver android:name="com.forsale.forsale.appboy.AppboyGcmReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.forsale.forsale" />
</intent-filter>
</receiver>
<receiver
android:name="com.forsale.forsale.appboy.AppBoyOpenReceiver"
android:exported="false" >
<intent-filter>
<action android:name="com.forsale.forsale.intent.APPBOY_PUSH_RECEIVED" />
<action android:name="com.forsale.forsale.intent.APPBOY_NOTIFICATION_OPENED" />
</intent-filter>
</receiver>
Know I can send in app message using app boy dashboard, and receive the message, but when I click the message it open appboy web activity with the link
I need to override this behaviour to be able to get the link that I sent in In app message and parse some parameters from it and direct the use to an activity inside my app
I have tried the following
remove default app boy web activity from manifest file /// the app crash
implement the IInAppMessageManagerListener /// the app stop receiving any messages
Please note that the application call the onReceive method when trying to register appboy and print the log (action = REGISTRATION, RegId = "..."), but it never lo any other actions like RECEIVE, or OPEN
public void onReceive(Context context, Intent intent) {
AppboyLogger.i("AMIRA", String.format("Amira %s", intent.toString()));
String action = intent.getAction();
AppboyLogger.i("AMIRA", String.format("Amira %s", action));
Bundle bundle = intent.getExtras();
for (String key : bundle.keySet()) {
Object value = bundle.get(key);
AppboyLogger.i("AMIRA", String.format("Amira %s", key + ":" + value.toString()));
}
}
The root of the problem is that we differentiate deep links and http links based on schema of the URI, so http (and some other schemes) links are detected as web links, and other formats are seen as deep links (see https://github.com/Appboy/appboy-android-sdk/blob/master/android-sdk-ui/src/com/appboy/ui/actions/ActionFactory.java).
We’ll consider how to instrument things for the use case you have, but in the meantime there’s a couple of ways you could solve the issue:
1) Create a deep link that is not also an http link. Everything should work if your link instead looks like, for example, forsale://mylink?a=b&2=3....etc.
2) Set a custom in-app message manager listener: https://documentation.appboy.com/Android/#in-app-message-customization. You can see an example of how we do this in our Droidboy sample app. In your case, you’d want to return defaults for everything but onInAppMessageButtonClicked and onInAppMessageClicked where you’d want to handle the link yourself if it’s of the format of your deep link. Your ticket indicates you’ve tried this, but I’d suggest starting with "the default one we create in the AppboyInAppMessageManager.java (#L608) in the Android SDK - and then just modifying the *clicked methods.
3) Download our UI code and modify the source. You could optionally download the Appboy Android SDK and modify the ActionFactory to handle your deep link in the way you want. Though, at the point you are going to do something like this, solution #2 is likely going to be a nicer one to implement and maintain.
Please let us know if one of these solutions works for you and if you have any other comments/questions.
Thanks,
Waciuma

How to install applications programatically from play store

I want to install app from play store on button click event,and after user click button manage status of downloading.
Suppose i want to download facebook from my app on a button click then, on a button click it should install on my device and i can get status of app is downloading/installing/pause/cancelled downloading.
Is this possible?
Please provide your idea for this.
Thanks in advance.
EDITED
i found below code to check download event broadcast -
<receiver android:name="com.test.MyReceiver" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
and i have broadcast receiver -
public class MyReceiver extends BroadcastReceiver{
#Override
public void onReceive(Context context, Intent intent) {
Bundle data = intent.getExtras();
String referrerString = data.getString("referrer");
Toast.makeText(context, "downloading....."+referrerString,Toast.LENGTH_SHORT).show();
}
}
but my broadcast receiver is never got called.
for downloading app on button click if using below link -
http://market.android.com/details?id=your.application.package.name&referrer=my_referrer_finally_works_fine
This is not possible. Not sure what else to say.
You can't download an app from the play store.
You can show the user the play store app with the correct app page, so they can download, see How to open the Google Play Store directly from my Android application?

how can I pass data to android Market using the new scheme on chrome?

so I noticed according to here, you can put a link on the site and have user to click on it. If user had the app installed, app will be launched. If the app wasn't installed, Google Play Store will be launched and search for the particular package, which is a great feature!! but from my understanding, this will loose the ability to pass referral string to play store.
According to here, you can have a link like market://details?id=your.package.name&referrer=YourReferrerString. If a broadcast receiver is set in the app, you'll be able to catch the referrer string, but how can I achieve the same goal if I used the first method which is from here?
here is the only thread I can find that talks about the new (?) feature on Chrome, but it didn't seem to answer my question.
Thanks!!
Turns out to be quite simple. The default referrer from Chrome is 'com.android.chrome'. Override this by putting &referrer= after package in your intent:// URI, for example:
var g_intent = "intent://" + code +
"/#Intent;scheme=yourscheme;package=com.your.app&referrer=code%3D" +
code + ";launchFlags=268435456;end";
Here's a gist that explains the javascript part of the solution more fully and also falls back to a normal market link if the intent:// scheme doesn't work: https://gist.github.com/akent/dec1b4b7383436b4623e
And in your Java code:
public static class InstallReferrerReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
String referrer = intent.getStringExtra("referrer");
// Do things with your referrer here
}
}
And in AndroidManifest.xml:
<receiver android:name=".YourActivity$InstallReferrerReceiver" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>

How do I access the user calls to mobile?

I want my application to be activated when the user make a specific call. Is there any way to take information which call is making by user in the same time ( not afterwords ) in order to activate the app at the right time ?
Ok i wrote this code for my case and it works:
public class OutgoingCallReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
if(null == bundle) return;
String phonenumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
if( phonenumber.equals("11111111") ) {
Intent myactivity = new Intent(context, MyKeyboard.class);
myactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(myactivity);
}
}
}
In the Manifest i add this:
<receiver
android:name=".OutgoingCallReceiver"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL"/>
</intent-filter>
</receiver>
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>
I don't really know, but I think that's a really dangerous practice. It all depends on what you intend to do with your app. If it's a recording app, I think you can't even think of developping it, or don't post on the internet about it because it would be illegal in many countries. That's how I see and how I feel your question. About Android there is not 15k places to search, have a look at the android API.
http://developer.android.com/reference/android/provider/CallLog.Calls.html
This, for example, I don't know if it's a real time log, or if it's filled after the call is terminated. But you can search in that direction.

Categories

Resources