开发者

How to detect the same user in different iPhones?

We're building an iPhone app which should store some info in a server.

We were planning to use the iPhone ID to store this info, but we've come across a problem: if the user switches from his iPhone 3Gs to the new 开发者_如何学PythoniPhone 4G, the iPhone ID will naturally change, but the user is still the same.

Is there a way, from the iPhone app, to detect some sort of user ID rather than the iPhone ID, so we hold to that when saving the info in the server?

Note: we could indeed do a register/login mechanism, so when the user logs in the proper info is pulled from the server, but we were thinking that if we can do without the login that'd be awesome.

Thanks!


You can use Game Center to authenticate the user but unfortunately it is only available in iOS 4.1 and later.

You can authenticate the user that is logged in to the device with authenticateWithCompletionHandler method of GKLocalPlayer. If the user has already logged in the user is authenticated and later you can ask for its id using:

NSString* userId;
userId = [[GKLocalPlayer localPlayer] playerID];

Then, you can use this id to find the users with multiple devices. Note that it is also possible to have multiple game center users within the same device.

If the user hasn't already logged in to game center iOS handles the login and registration but user may choose not to login.

You can find more info at Game Kit Programming Guide.


Unfortunately, there is nothing your app has access to that would be unique across two different devices/same user. You can't even get the App Store user ID.

Unfortunately, you have to tie it in some way to an account on your system.

You could look at the push notification system (APNS). APNS provides a device token that you can use. However, it is not unique for user, but unique for device. So that still doesn't give you a solution.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜