How get the unique identify for phone device under ios or android.
I don’t know how to get the unique identify under ios and android using c**.
I know under android I can use java like this TelephonyManager.getDeviceId()
to get the device id .
and how can i use c** to get this, and how can i use c++ to get the ios device id.
You can invoke java code via jni. Refer
cocos2d-x/CocosDenshion/android/jni/SimpleAudioEngineJni.cpp
cocos2d-x/HelloWorld/andorid/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java and
cocos2d-x/HelloWorld/andorid/src/org/cocos2dx/lib/Cocos2dxMusic.java.
On iOS, you can get the device id by:
[[UIDevice currentDevice] uniqueIdentifier]
It is written by object-c, but it can be mixed used with c++.
Rename file to xxx.mm, then you can use c*+ and object-c in the file.
For detail information, you can research mixing usage of c*+ and object-c by google.
I think there should be a unified API which will return the unique id of the device.
It doesn’t make sense for all of the developers [who need this, obviously]to write custom code to get it.
Currently cocos2dx supports: ios, android, bada, nokia[?], blackberry [?], others… and if one wants to release version of the game for all of the devices, it would be cool to have one single api to call to get the number.
I am sending this information in all of requests to the server and now I’m facing a problem - how to get this id on all of the platforms.
Looking at the new iOS policy I don’t think there’s any other method.
I am not sure how it works on devices before 5.0, I will have to take a look once I’m back in the cocos2d-x project.
What I know is that we can’t have 2 methods for checking the device id.
Developers should adapt to the new way and change their code in games.
In our project we use deviceId as a first way to identify user [before they create account]. If the deviceId changes, they will loose all the data.
Also take a look at the first comment on the page I gave link to.
Storing the id in the keychain might be a good way to go, but still I think user will be able to “wipe” the device and loose the previously saved device id.
Damn
Guys I need this too. It is very important and I can not workaround getting device unique id. What is the status of feature 932? It was opened 1.5 years ago and still no progress as I see. But there should be some approaches/codes, people have used all this time. Maybe someone can share his experience?
BTW I don’t know in other cases, but in my case I don’t need any real hardware ID (network card mac address, IMEI or so). I just need to identify different devices. In other words, the enumeration (actually generating UUID on each device once) of devices that play my game would be just fine. And I think lots of people will need just this to identify the device.
Is it possible to realize the following scenario with cocos2d-x existing API? Generate a UUID on the first run of the application on the device and serialize it. And even if the app will be uninstalled and installed later, the UUID will be serialized in a “safe” place and it can be reused instead of generating a new UUID on each install. In order to do this I need:
UUID generator which works on all cocos2d-x supported platforms
a place to serialize UUID that will not be deleted when the app is uninstalled, and is far from the eye of the user, so he could not delete it manually