I would like to send a welcome message notification to apps installed from the Play Store.
Example :
Thanx for installing this app and share it with your friends, if you like more rate my android app.
Is it possible to do this?
I would like to send a welcome message notification to apps installed from the Play Store.
Example :
Thanx for installing this app and share it with your friends, if you like more rate my android app.
Is it possible to do this?
you could possibly do something like this to know the app install event
In the manifest file:
<receiver android:name=".YourReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_INSTALL" />
<action android:name="android.intent.action.PACKAGE_ADDED" />
<data android:scheme="package"/>
</intent-filter>
</receiver>
In the java code
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
intentFilter.addAction(Intent.ACTION_PACKAGE_INSTALL);
intentFilter.addDataScheme("package");
registerReceiver(br, intentFilter);
private void checkVisit() {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = sharedPreferences.edit();
int numberVisits = sharedPreferences.getInt(NUMBER_VISITS, 0);
if(numberVisits >= 10){
boolean notificationSent = sharedPreferences.getBoolean(NOTIFICATION_SHOWN, false);
if(!notificationSent) {
sendNotification();
editor.putBoolean(NOTIFICATION_SHOWN, true);
}
} else{
editor.putInt(NUMBER_VISITS, ++numberVisits);
}
editor.apply();
}
private void sendNotification() {
Bitmap icon = BitmapFactory.decodeResource(getResources(),
R.mipmap.ic_launcher);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setContentTitle("Thanks for downloading !")
.setContentText("If you liked the app, please rate us")
.setSmallIcon(R.mipmap.ic_launcher)
.setLargeIcon(icon)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText("If you liked the app, please rate us"))
.setContentIntent(PendingIntent.getActivity(this, 0, new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + "YOUR PACKAGE NAME GOES HERE"))
, 0))
.setAutoCancel(true);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, builder.build());
}
Call checkVisit onCreate in MainActivity, this will fire a notification on his 10th visit. When the user clicks the notification it will take him to the store directly to your app where he can rate it