1

My play store account has over 100 apps published and all of them have this common user generation process which includes OTP verification. Interesting to note is all the apps have same user object with same properties for a particular OTP verified number, which gets stored in the respective SharedPreferences as string.

For better User Experience I would like to trim down the user generation process if there is any one app installed in the device and has done OTP verification. I want to share this user object, which is saved as string in each app's SharedPreferences.

So here's what I want when I install com.domain.app.cX app:

1) com.domain.app.cX -> (Do you have a verified user?) -> com.domain.app.cY

2.1) com.domain.app.cY -> (Yes I have, here is it "user json") -> com.domain.app.cX

or

2.2) com.domain.app.cY -> (No I don't have any user) -> com.domain.app.cX

3) Move to check if com.domain.app.cZ is installed and do over from step 1

Options I have:

1) I have read about ContentProvider and understood that you need to put in a URI of ContentProvider which is package name specific.

2) Use package name with createPackageContext and get SharedPreferences for any app.

In both the solutions I don't know which app is already installed on device and hence URIs of all ContentProvider and package name of the app.

Is there any solution in which I can leverage the signature of the app, since all the app are signed with same certificate.

Harsh Vardhan
  • 675
  • 1
  • 11
  • 24
  • Is your domain name same for all the apps? – Kalpesh Patel Sep 07 '16 at 12:01
  • its goes like com.companyname.property.c123 and com.companyname.property.c127. 123 and 127 being the id of the property in central system. – Harsh Vardhan Sep 07 '16 at 13:54
  • You can get list of installed apps and then match their package names with your domain name. If you find any package, then query its content provider and get the logged in user info. – Kalpesh Patel Sep 07 '16 at 14:28
  • Thanks Kalpesh. Yes that is one possibility, but that is one more permission and like I mentioned we are adding more apps each day. This loop will take a lot of time in processing and at the start up of an app it might be a big turn off for a user. And I can do this in background since I have to show login/sing-up screen in case a user is not found. – Harsh Vardhan Sep 07 '16 at 15:01
  • Ohh I understand. Did you look at this. http://stackoverflow.com/a/29170236/1282812 This could be easy solution. Since it is shared prefs you can use it on main Thread, Also even if user have your 100 apps installed, Practically you will not need to iterate over 100 apps. Mostly you will get user info in 4th or 5th iteration. – Kalpesh Patel Sep 08 '16 at 07:10
  • PS. This requires your app to be signed with same key. which should not be problem for you, as you are signing with the same key. – Kalpesh Patel Sep 08 '16 at 07:11

1 Answers1

0

Using Broadcast receivers and Custom Broadcasts. with redundant common data across all apps with shared preferences.

All the apps contain a pair of broadcast receiver and sender. The app which wants verification status will send a broadcast. The other apps which listen to the broadcast will receive it and add the verification status in the intent and send again as a broadcast. Now the 1st app which send the broadcast for verification status will receive the latest status and update the UI accordingly. If the default value is false then show the verification screen.

Gnanendra Kumar
  • 1,096
  • 11
  • 11