I want the users of my app to sign in through a single device only at the same time. How do I achieve this?
You may add device id in Firebase on register and check it on login. You can get the device id as follows:
private String android_id = Secure.getString(
getContext().getContentResolver(), Secure.ANDROID_ID
);
Or you can browse here.
Related
Prelude:
The client wants to install EMM for his owner devices. Sometimes the user wants to use the device as work device (only taxi and couriers apps) and sometimes the user wants to use the device as his own (install games, social apps, and his own Google accounts).
Situation:
The client wants to store his gsuite accounts in FRP storage (to have the ability to unlock a phone in case employee leave organization) but doesn't want an employee to unlock the phone after FR entering his personal account credentials.
Example:
I added two work account programmatically (like described here). But after the user gets the phone he entered his personal Gmail account to use Gmail, other apps. How can I programmatically or maybe from DPC app prevents user recover access to the phone using his personal account after Factory Reset?
I found the answer, finally. The link to the documentation.
I need just to create a bundle with google plus ids of accounts that will have the opportunity to recover device after factory reset.
And after that need to send a broadcast to notify the system that these values were changed.
val bundle = Bundle()
// list of recovery accounts
val recoveryAccounts = arrayOf(
"115273111154663031432",
"110369192556268846321",
)
bundle.putStringArray("factoryResetProtectionAdmin", recoveryAccounts)
mAdminComponentName = DeviceAdminReceiver.getComponentName(context)
// set restrictions
mDevicePolicyManager.setApplicationRestrictions(mAdminComponentName, "com.google.android.gms", bundle)
// send broadcast
val broadcastIntent = Intent("com.google.android.gms.auth.FRP_CONFIG_CHANGED")
broadcastIntent.setPackage("com.google.android.gms")
broadcastIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND)
applicationContext.sendBroadcast(broadcastIntent)
Off topic.
To get the id of recovery accounts try this: https://developers.google.com/people/api/rest/v1/people/get?apix=true&apix_params={"resourceName":"people/me","personFields":"metadata"}
Push "Execute" and login with needed account. It'll be shown in "id" field of response.
I'm currently planning on creating an app. Unfortunately the need for usercreation is there. I know users don't like goind through a registration process with opt in by email activation link click.
So I thought maybe using the apple/google id as a replacement for email address would be cool since the verification step by email can be dropped. In addition when the user changes his or her mail address that's no problem since his or her id doesn't change in this case.
I'm not really into this particular topic so I have some questions, any help is highly appreciated:
Is there any numeric/alphanumeric id anyway or is the google/apple id (i.e. the "username") the email address itself?
Is this possible in Android and Apple SDK (and Cordova in addition since I use this one)?
Is this a good idea in general or am I missing something?
Thanks in advance!
You could use the below DeviceIDs solutions as primary key for your users registrations. Look:
1 - Android
1.1 - Android Phones (With SIM chip) - For Android I use the Cordova SIM plugin. It generates uniqueIDs for devices based on SIM chip informations. So, you can manipulate your data based on the plugins return;
Link: https://github.com/pbakondy/cordova-plugin-sim
1.2 - Adroid Tablets - The plugin above is fantastic, but it does not work for devices that does not have any SIM chip. In this case, I use the following code:
if(mContext == null){
mContext = this.cordova.getActivity();
if(dialog == null){
dialog = new ProgressDialog(mContext);
}
}
String tabletID = Secure.getString(mContext.getContentResolver(), Secure.ANDROID_ID);
Conclusion: If you are developing only for phones (App projected for Mobile Phone) you should use the plugin. If your App targets Tablets or devices without SIM card, than you can take a look at the other solution. The IDs generated are "Devices ID", unique for each device.
2 - iOS
For iOS, I use the following code to generate an unique ID for each device:
NSString *uniqueIdentifier = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
The only problem: When user uninstalls all Apps of your iTunes vendor ID from the device and installs any of them again, the ID will be changed. Other easy ways to get Unique ID for iOS is deprecated since version 7.0 of the system.
See more here: Device Id from an iphone app
I am considering having my own website to sell my android app. After someone purchase my app I want that user's device id to be stored on my server so that when my app sends licensing data to my server, I have that device's id already store there. My app will verify that device id and will allow further access to the app.
So my question is, that is there any way I could fetch the unique device id of the device which actually pays for my app on my website??
Every answer is appreciated.
you can use this code :
private String android_id = Secure.getString(getContext().getContentResolver(),
Secure.ANDROID_ID);
but you have to use it at your own risk!
and I think it's no longer unique from android 4.2
You can use this:
TelephonyManager tm = (TelephonyManager) getBaseContext().getSystemService (Context.TELEPHONY_SERVICE);
String tmDeviceId = "" + tm.getDeviceId();
I am developing a android application for a exploratory project using client server architecture. I thought of using UDID but now its replaced by new "Advertising ID", but in my application, i need to store data about user on server with some unique ID per device.
so what should i use as alternative to UDID?
i checked open UDID but that is also outdated now.
Using "advertising ID" imposes problem of consistency when user clears/resets his advertising ID.
Request the community to help me out.
There is also identifierForVendor see more in apple docs
I don't have much idea about Android :
But Check these :
GeneratingDeviceSpecificSerialNo && HEre
In IOS :
-identifierForVendor
ID that is identical between apps from the same developer.
Erased with removal of the last app for that Team ID.
Backed up.
For more Info Here
You can register the device with the Google Cloud Messaging platform.
When you register the device correctly this gives you back a register id that´s unique for every device.
http://developer.android.com/google/gcm/client.html
UPDATE
You can also, if you haven't tried it out yet, to user the telephony manager to get the device identifier.
TelephonyManager tManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String uuid = tManager.getDeviceId();
On iOS you can try this
NSString *UUID = [[NSUUID UUID] UUIDString];
This will give you a unique id per app.
I want to make an application which has to be very secured. So f I install an apk in a phone it should only work in that phone. When apk is shared it should not work.Can any one help me in implementing this.
One idea from my side is using an algorithm to generate password using device mac address and so the password won't work for two different devices to log in.Is there any way to get the MAC address( or something unique to device) in android from java? .Expecting alternate solutions!!
If you are distributing the app through Google play store, you can make use of the Google Play Application licensing.
You may read Identifying App Installations on Android Developer's Blog for a discussion about how to uniquely identify a device.
I implemented with IMEI number. So my apk is designed based on IMEI number.So it will check whether IMEI given matches with the device IMEI then only it will launch the new Activity, else it will exit.
TextView tx = (TextView) findViewById(R.id.tx);
String ts = Context.TELEPHONY_SERVICE;
TelephonyManager mTelephonyMgr = (TelephonyManager) getSystemService(ts);
String imei = mTelephonyMgr.getDeviceId();
if (imei.equals("<what we given inthe source>")) {
// Launch the activity
} else {
// show an alert dialog and exit
}