Check if an ios device was blocked [duplicate] - ios

This question already has answers here:
UIDevice uniqueIdentifier deprecated - What to do now?
(32 answers)
How to preserve identifierForVendor in ios after uninstalling ios app on device?
(8 answers)
Closed 4 years ago.
Is there a way to identify a device which was blocked by my app, so they cannot create a second account?
I have read a little bit about Unique Identification and DeviceCheck, Apple's own IPA. I also considered to ask for the phone number when the user signs up, but this seems a little complicated for me and the other solutions only work if the user is kind enough no to reinstall the app.
On other approach I had was to get some information (Carrier, iPhone Name, iOS Version, iPhone Model etc.), pack it into one String and use it as an unique id, but some of this information can be changed easily and I don't think Apple would like this solution.
I am sure that there are better/simpler solutions.
(This task seems very easy in Android. I plan to use this statement: UUID.randomUUID().toString();)
That info could help:
I am planning to connect this app to Firebase.
In the best case, the solution would work from iOS 8.0 to the current iOS Version.
I am open for any kind of creative solution in Swift or Objective C.

We can achieve this by using SSKeychain. Using SSKeychain once we have set value for particular in the SSkeychain then that value will remain their even we have removed that application from your ios device.
Please check following e.g Objective- C
if([SSKeychain passwordForService:#"your application bundle identifier" account:#"user"] == nil)
{
NSString *UUID = AppDelegate.GetUUID;
[SSKeychain setPassword:UUID forService:#"your application bundle identifier" account:#"user"];
NSString *retrieveuuid = [SSKeychain passwordForService:#"your application bundle identifier" account:#"user"];
NSLog(#"retrieveuuid %#",retrieveuuid);
}
+ (NSString *)GetUUID {
CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, theUUID);
CFRelease(theUUID);
return (__bridge NSString *)string;
}

Related

How to programmatically get phone number with iOS11 for Enterprise app

Yes I know full well its not possible to get the phone number using public APIs.
I want to know what the latest situation is regarding how to get the phone number using private APIs for an enterprise app with iOS11.
All the past questions I could find are years old, couldn't find anything recent.
I tried this:
extern NSString* CTSettingCopyMyPhoneNumber();
+(NSString *) phoneNumber
{
NSString *phone = CTSettingCopyMyPhoneNumber();
return phone;
}
But am not able to run this however as I wasn't able to add the com.apple.coretelephony.Identity.get entitlement without getting a signing error saying the executable was signed with invalid entitlements.
Is it still possible with iOS 11 to get the phone number programmatically using non-public APIs for an enterprise app on a non jailbroken device?

Unique Identification of iOS device for iOS 7.0 and above

Looking for your help
I am facing a problem while getting Device Identifier. Actually I am using a UIDevice+IdentifierAddition.h, NSString+MD5Addition.h classes to get Identifier, but its return same identifier for all my devices i.e. iPhone 4s (iOS 7.1) & iPhone 5 (iOS 7.1.1).
Can any one have any solution for this problem. because I want a something unique for device specific. its my app requirement.
Important: I want to submit this app on app store, So please, answer must be as per the guidelines
Since iOS 7 it is no longer possible to get any unique device identifiers.
Your options are:
create your own unique ID and save it in the keychain.
use the vendor ID, which will be reset if all the app by the same vendor are removed from the device.
Now it's possible in iOS 11.0+, Apple has introduced a new API called DeviceCheck API with which developers can uniquely identify a device.
As mentioned in the documentation:
Using the DeviceCheck APIs, in combination with server-to-server APIs,
you can set and query two bits of data per device, while maintaining
user privacy. You might use this data to identify devices that have
already taken advantage of a promotional offer that you provide, or to
flag a device that you have determined to be fraudulent. The
DeviceCheck APIs also let you verify that the token you receive comes
from an authentic Apple device that includes your app.
Also, check out the following WWDC17 video starting at 24 min:
https://developer.apple.com/videos/play/wwdc2017/702/
EDIT:
A thoroughly detailed tutorial on this Device Check topic can be found here.
In Objective c
NSString *uniqueIdentifier = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
In Swift
var uniqueId=UIDevice.currentDevice().identifierForVendor.UUIDString as String
println("Your device identifires =>\(uniqueId)")
Unfortunately identifierForVendor changes when you uninstall your application so to guarantee that the it will not change save it in the keychain
I used pod 'SSKeychain' Homepage: https://github.com/soffes/sskeychain
Here is the code
+ (NSString *)getDeviceId {
NSString *appName=[[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleNameKey];
NSString *strApplicationUUID = [SSKeychain passwordForService:appName account:#"MY_KEY"];
if (strApplicationUUID == nil) {
strApplicationUUID = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
[SSKeychain setPassword:strApplicationUUID forService:appName account:#"MY_KEY"];
}
return strApplicationUUID;
}
[UIDevice uniqueIdentifier]; is deprecated in ios 5 and above.
You can get identifier for vendor using this
NSString *udid = [[UIDevice currentDevice] uniqueIdentifier];
and store this in keychain and use later on.
Also you can check for
1) NSUUID
2)CFUUID
you will get detail description here Unique device identification in ios
If you're trying to identify a device only once i.e., to estimating the number of unique users then I suggest using "advertisingIdentifier" of ASIdentifierManager.
Apple Doc

UDID Replacement in IOS7

Is there is a alternative for UDID. My app will not be going to App Store as i'm using enterprise distribution. So is there any replacement. I tied advertising identifier, open udid, UIID and secure UDID. But if the phone is reset then i will get a new UDID. Any help would be appreciated.
For above 6.0 iOS you can use identifierForVendor Or CFUUIDRef.
-(NSString*)uniqID
{
NSString* uniqueIdentifier = nil;
if( [UIDevice instancesRespondToSelector:#selector(identifierForVendor)] ) {
// iOS 6+
uniqueIdentifier = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
} else {
// before iOS 6, so just generate an identifier and store it
uniqueIdentifier = [[NSUserDefaults standardUserDefaults] objectForKey:#"identifierForVendor"];
if( !uniqueIdentifier ) {
CFUUIDRef uuid = CFUUIDCreate(NULL);
uniqueIdentifier = ( NSString*)CFUUIDCreateString(NULL, uuid);
CFRelease(uuid);
[[NSUserDefaults standardUserDefaults] setObject:uniqueIdentifier forKey:#"identifierForVendor"];
}
}
return uniqueIdentifier;
}//
UPDATE
As Leon Lucardie comment he is right
identifierForVendor will change after app uninstall/reinstall. See here The value in this property remains the same while the app (or another app from the same vendor) is installed on the iOS device. The value changes when the user deletes all of that vendor’s apps from the device and subsequently reinstalls one or more of them.
You have to create vendor id then save it using keychain and get it back once you reset your phone using date time
check this link UUID and UDID for iOS7
After trying all possible replacements. Advertising identifier is the best way to go. It remains same even after phone reset when i tested. If the user turn it off in the settings then we get a null value. Except for this hitch, this is the best replacement so far. Will update if i find any other better replacements.
Easy, Just use this code:
-(NSString *)getUID{
if ([[UIDevice currentDevice] respondsToSelector:#selector(identifierForVendor)]) {
// This is will run if it is iOS6 and above
return [[[UIDevice currentDevice] identifierForVendor] UUIDString];
} else {
// This is will run before iOS6 and you can use openUDID or other
// method to generate an identifier
return [OpenUDID value];
}
}
As you can understand, if you plan to support iOS 5 then you should use OpenUDID (Apple restrict reading the UDID even on iOS 5). With some answers here you would simply get rejected by Apple (my code has been approved in several apps of mine).
Pay attention that identifierForVendor would change if your user would remove the app (or all vendor apps if there are several) and reinstall.
I use the combination APNS token and vendorId. Both are checked to verify cellphone identity and I update them accordingly in cellphone and server when one of those change.
It´s still possible that both change, when the app is uninstalled and/or reset and stored for a few months, then both values would change.
This will cause that next time the cellphone gets the app installed, it will be identified as a new one.
Additional to this I run a process in server that marks as deleted any device which hadn't connected to the server for two months.
In that case user authentication is required and cellphone is added again to the customer's pool of devices.
I have only one app yet, but once I have the second one I might include advertisingId.
These blog posts by Ole should be helpful:
iOS 5: http://oleb.net/blog/2011/09/how-to-replace-the-udid/
iOS 6+: http://oleb.net/blog/2012/09/udid-apis-in-ios-6/
You can use after ios 6+ with Swift 2.2 version.
var uniqueIdentifier: NSString!
uniqueIdentifier = UIDevice.currentDevice().identifierForVendor?.UUIDString

Unique iOS Device ID Across Applications [duplicate]

This question already has answers here:
UIDevice uniqueIdentifier deprecated - What to do now?
(32 answers)
Closed 9 years ago.
I'm currently working on a suite of iOS applications that will be using the same server for authentication. The server uses a UDID for device authentication. I'm aware that uniqueIdentifier is now deprecated, so I'm wondering what the best practice is for having a unique identifier across applications? (I know how to generate my own and store it in the keychain, but this will be application specific) I have seen postings about identifierForVendor and identifierForAdvertising
The docs say:
[uniqueIdentifier is] deprecated in iOS 5.0. Use the identifierForVendor property of this class or the advertisingIdentifier property of the ASIdentifierManager class instead, as appropriate, or use the UUID method of the NSUUID class to create a UUID and write it to the user defaults database.
As we know uniqueIdentifier is deprecated in iOS 5.0 so docs recommend you to use CFUUID
instead.
You can get CFUUID using
CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
NSString *uuidString = (NSString *)CFUUIDCreateString(NULL,uuidRef);
CFRelease(uuidRef);
Please save the uuidString in user defaults or in other place because you can not generate the same uuidString again.
Hope it helps you.

iPhone/iPad unique identifier BESIDES UUID/UDID?

The project I am on is requesting two (or even three) unique identifiers from the iPhone or iPad. I know, I know... the UDID should be enough but we are trying to see if there are any other unique identifiers that we can use.
I can get the IMEI, serial number, MAC Address, etc. from the phone using the IOKit.framework but apparently this is frowned upon by Apple and any app using this framework will be rejected.
Does anyone have any other ideas, or identifiers that I am missing that could be used?
Thanks!
This question is old however a new unique, vendor based, identifier has now been added to replace the deprecated UUID in iOS 6.
The [UIDevice identifierForVendor] should now be used instead of [UIDevice uniqueIdentifier] which is now deprecated as of iOS 5.0
Example usage:
NSUUID *uuid = [[UIDevice currentDevice] identifierForVendor];
NSString *uuidString = [uuid UUIDString];
You can get the ICCID and the IMSI (if they exist).
NSString *commcenter = #"/private/var/wireless/Library/Preferences/com.apple.commcenter.plist";
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:commcenter];
NSString *ICCID = [dict valueForKey:#"ICCID"];
NSString *IMSI = [dict valueForKey:#"IMSI"];
I think that's as far as you will get. I don't know any other options for getting an universal ID.
UPDATE 2013-03-13:
This has probably changed since I wrote this answer almost two years ago. I don't even remember what was the iOS version at the moment. Also as #joshis correctly pointed out in the comments "You cannot legally do this, since your app would read stuff from outside the application sandbox and therefore, it will be rejected, as specified in AppStore Review Guidelines...".
From Apple:
The value in this property remains the same while the app (or another
app from the same vendor) is installed on the iOS device. The value
changes when the user deletes all of that vendor’s apps from the
device and subsequently reinstalls one or more of them.
So if you use [UIDevice identifierForVendor] and the user delete the app and reinstall it, the id will be different(so no real physical device tracking)
Why don't you use SecureUDID?
NSString *domain = #"com.example.app";
NSString *key = #"mykey";
NSString *udid = [SecureUDID UDIDForDomain:domain usingKey:key];
This way, even if the user delete the app and reinstall it, the UDID will be same. This will give you consistent tracking(or whatever you want to do with the UDID).
Btw, the above is still permitted from Apple.
Have fun.
The method for getting the UDID is being deprecated, you should now use CFUUIDCreate which I think could be used multiple times to get more identifiers if needed
Perhaps you should clarify your question.
requesting two (or even three) unique identifiers from the iPhone or iPad
…is a contradiction in terms. If your purpose is to track a specific physical device, then a single unique identifier, by definition, is enough. That’s what unique means.
Perhaps, what you really want is to track multiple things about each user’s use of your app, as opposed to the device. Say your networked game app allows the user 1, 2, or 3 different personalities. As they user creates a distinct personality, you must track each of that user's personalities amongst all the other user’s personalities.
For this kind of purpose, generating and storing a UUID* is a proper and common solution. iOS includes libraries to generate a UUID value. The only catch is that if the user deletes and re-installs the app, the storage of that UUID may be lost. There are workarounds for this challenge, which you may learn about by googling for discussions of replacing UDID tracking with generated UUID values.
This question is a bit older. So I should mention: In iOS 5, Apple deprecated the use of the UDID. As of 2013-05-01 Apple is rejecting any app that accesses the UDID.
(*) Do not confuse a UUID with a UDID. UUID is a standard 128-bit (32 hex digits) number often used as a virtually unique identifier in many technology scenarios. UDID is Apple's 40 hex digit string burned into every iOS device to uniquely identify each device.
DeviceCheck API in iOS 11 is an interesting solution to get unique Identifier, the advantage it has is - the value will be retained even after the app in uninstalled. So use cases like trial installation and rewards can be effectively controlled by developers.

Resources