Skip to main content

Generate Device Identifier

Generate Device Identifier

Android

To fetch the Android device identifier, use the following code:

String android_id = Secure.getString(getContext().getContentResolver(), Secure.ANDROID_ID);

Troubleshooting

  • If you are facing the following exception: "java.security.InvalidKeyException: Illegal key size or default parameters", visit this link.

iOS

To fetch the iOS device identifier, use the following Swift code:

import UIKit

if let deviceId = UIDevice.current.identifierForVendor?.uuidString {
print("iOS Device Identifier: \(deviceId)")
} else {
print("Failed to retrieve iOS Device Identifier")
}