I need to get a unique number for every device for my cordova app (iOS/Android) The ID must be the same when user closes the app or install a new version
I cannot used the UUID from the "cordova device plugin" because the UUID changes when the user upgrade to a new version so it wouldn't work for me.
I have tried generating a unique number and storing it on the phone. However, I run into an issue where the information is not persisted.
This happens when the user install the app and then remove the app from the background. Otherwise , the data is saved
any ideas?
You can use the serial number of the phone as a unique identifier
One possibility is to use cordova-plugin-cloud-settings which allows you to persist user settings in cloud storage across devices and installs.
Install it:
cordova plugin add cordova-plugin-cloud-settings
Use it to store a GUID:
var settings = {
GUID: 12345678
}
cordova.plugin.cloudsettings.save(settings);
The nice thing about this solution is it doesn't need any special user permissions.
If you really want a unique device ID (vs unique user ID) then you could use the UniqueDeviceID plugin.
However, note that on Android this uses the SIM ID to obtain an identifier so requires READ_PHONE_STATE permission which displays a user permissions prompt "Allow to make and manage phone calls", which is not great for the trust of your users.
Use the MAC address:
cordova plugin add cordova-plugin-ip-mac-address
var params = {};
addressimpl.request("getMACAddress", JSON.stringify(params), function(message) {
alert("mac address "+message);
}, function() {
alert("failed on get mac address");
});
From here
Related
I'm building a mobile app for iOS and Android using ionic 2. I want the users' accounts to be device based so the users do not need to manually register or authenticate. How is this usually achieved?
why dont you use this plugin and get the device info
Ionic Native Device
So you can access these information
Device uuid
Manufacturer
Serial
And then create a unique ID by combining or with any Algo
Example :
import { Device } from '#ionic-native/device';
loginid:any;
constructor(private device: Device) {
this.loginid = device.uuid+device.serial;
}
Use this LoginId to Auth the user Automatically. Hope this helps.
Thanks :)
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
please don't make my post like as duplicate why because am totally confused with those post when i google it.
but i need your valuable statements and real time experience on How to get UNIQUE IDENTIFIER for iOS,Android and Windows Mobiles
i have a scenario that when user login with UserName and Password i send details to server at same time i need to send Device UUID. By using device UUID and User Credentials am going to Restrict second user login when first user is already logged in(Active). but am confused with getting iOS Device UUID but wheen i seen in many post iOS is killing apps in App store when app is Accessing any UUID values.
please suggest me better way to complete mytask.
Link-1
Link-2
sorry for my bad english....!!!
You can use the Unique Device ID plugin.
Install it:
cordova plugin add cordova-plugin-uniquedeviceid
And use it:
window.plugins.uniqueDeviceID.get(function(uuid){
console.log("Unique ID": +uuid);
}, function(error){
console.error(error);
});
This will give you a unique ID per device that persists between installs.
Note that on Android 6 it requires telephony run-time permission to access SIM ID. Also you may need to fork it and update it to get the Windows Phone 8 code working on Windows 10 Mobile.
in the case of angular
you gotta install ngx-device-detector via npm then import it on your module and in the import section add DeviceDetectorModule.forRoot().then in the component you're gonna use import it and add private deviceService: DeviceDetectorService this in the constructor it will generate u a method and add it on the constructor this.epicFunction(), if it doesnt paste this
epicFunction() {
console.log('hello `Home` component');
this.deviceId = this.deviceService.getDeviceInfo();
const isMobile = this.deviceService.isMobile();
const isTablet = this.deviceService.isTablet();
const isDesktopDevice = this.deviceService.isDesktop();
console.log(this.deviceId);
console.log(isMobile); // returns if the device is a mobile device (android / iPhone / windows-phone etc)
console.log(isTablet); // returns if the device us a tablet (iPad etc)
console.log(isDesktopDevice); // returns if the app is running on a Desktop browser.
}
note: the "this.deviceId" is a variable i created in the start of the class
in the case of android just import the security and add the permission on the manifest file
I am working on an APP using Xamarin MonoTouch, this App requires custom licence key as provided by us. To identify each and every installation we have to store some kind of device information to control misuse of App.
After trying various ways, now the problems are:
Device Id or Android id : gets changed every time a device is factory reset or format.
Settings.System.GetString(this.ContentResolver, Settings.Secure.AndroidId);
IMEI Number: No SIM Tabs dont have. Double SIM phones have no fix slot wise imei and sends randomly chose one.
var telephonyManager = (TelephonyManager)GetSystemService(TelephonyService);
string imei = telephonyManager.DeviceId;
WIFI Mac Address: Good way but some sets like HTC and Chinese ones throwing exception while retrieving mac address, but works some time. SO not getting fix id everytime app starts.
WifiManager wm = (WifiManager)GetSystemService(WifiService);
string macid = wm.ConnectionInfo.MacAddress;
So everytime any of the above ID fails, user needs to re register app again and again. Do we have any fool proof way of doing this?
Ok, as per comment by Matt, since there is not fool-proof method of getting unique id from an android device. So I have made a provision of validating installations against WIFI Mac ID and Android ID both. If any one of these found matched then installation is genuine or spoofed.
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.