1

A) In android i can get the SIM details and can specifically choose the SIM for sending the OTP from that SIM. I have a sample screen which is possible to implement in Android.

I followed the link for ios How can I get details about the device data provider (like Verizon/AT&T) of an iphone programmatically?

https://developer.apple.com/forums/thread/9171 This link states we cant get the SIM Phone numbers from device because of Apple Privacy policy

How to implement the same screen in iOS? Any alternative idea or help is appreciated

B) How to get the Unique id for authentication?

In Android we can get (IMEI+SIM Serial number) can be used for authentication but in iOS all these are restricted due to privacy . Instead it is impossible to get UDID which is unique for every device. I know i can use vendor id for this:

UIDevice.current.identifierForVendor!.uuidString

But as the documentation says: 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.

Since the vendor id changes when the user uninstalls the Application .So is it any way around to get a unique id other than Vendor ID for authentication which doesn't change and is unique all time?

User1075
  • 819
  • 15
  • 36
  • a) maybe redesign screen and let user to enter the phone number himself? b) no legal way to track if its unique device across installations – Neil Galiaskarov Aug 03 '20 at 19:58
  • @NeilGaliaskarov can you post this as an answer so that i can upvote it? Thanks for this comment .. Please explain more about your b) comment – User1075 Aug 03 '20 at 20:01

1 Answers1

2

How to get SIM phone number?

As it stated in the question, its not available to get the phone number due to the security reasons. I suggest you to have a textfield and let user to enter the numbers, so you can send the sms to verify it

How to get the Unique id for authentication?

You have two options here based on your deployment target needs:

  1. Apple has come up with the DeviceCheck framework in iOS 11. Your app should use the DeviceCheck APIs to generate an ephemeral token that identifies a device. Your associated server combines this token with an authentication key that you receive from Apple and uses the result to request access to the per-device bits. Very intentionally by Apple, DeviceCheck tokens can not be used to identify the specific device. But you can try playing to get unique identifier for the iOS device state

  2. Create your own unique ID and save it in the keychain.

References

Neil Galiaskarov
  • 5,015
  • 2
  • 27
  • 46
  • Thanks for the detailed answer So is it better to use vendorIdentifier as of now ? because my app needs to support iOS versions below iOS 11 too and Device check framework is available only for iOS 11 + – User1075 Aug 03 '20 at 20:50
  • `vendorIdentifier` is very unstable and I strongly not recommend you to use it. In my practice it has been changed even across app-updates. – Neil Galiaskarov Aug 03 '20 at 20:54
  • so what you suggest to use instead of vendorIdentifier ? – User1075 Aug 03 '20 at 20:56
  • Any help will be greatly appreciated. Is NSString *UUID = [[NSUUID UUID] UUIDString]; still usable instead of vendorIdentifier? – User1075 Aug 03 '20 at 21:01
  • Do you want it unique across installations? Imagine - user deletes the app and then reinstalls it, should you come up with the same id? – Neil Galiaskarov Aug 03 '20 at 21:02
  • Yes and the user can register only on one device at a time. He can't register in multiple devices. So if i want unique across installations what to do? Please suggest .. And if in case i don't want unique across installations what to do? Please explain in both scenarios. – User1075 Aug 03 '20 at 21:06
  • Long story short - you want be able to get unique id across installations especially lower than ios11... – Neil Galiaskarov Aug 03 '20 at 21:10
  • before I do it, do you know any iOS applications which works as you want? – Neil Galiaskarov Aug 03 '20 at 21:25
  • As of now no ... but the only requirement for me is to uniquely identify the device as android does. So that the user cannot register more than one device at the same time with deployment target iOS 9 and above – User1075 Aug 03 '20 at 21:30
  • 1
    I update my answer with second option which might help you – Neil Galiaskarov Aug 04 '20 at 06:27
  • Thanks for the answer. Can we send that unique ID generated in second option to the server? Is there any chance of apple rejection? – User1075 Aug 04 '20 at 06:33
  • No, you want be rejected, its a public api – Neil Galiaskarov Aug 04 '20 at 06:57
  • thanks for the help once again. Regarding sim , is there any way to determine the SMS being is sent from the SIM which is present in our phone. Means if i want to send SMS with a phone number which is not in our phone , it shouldn't allow sending message – User1075 Aug 04 '20 at 07:07
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/219166/discussion-between-neil-galiaskarov-and-fiona-shoff). – Neil Galiaskarov Aug 04 '20 at 07:10