Retrieve the user's App Store nickname programmatically - ios

Is anyone aware of a method to get the user's App Store nickname? I know about the CloudKit method fetchUserRecordIDWithCompletionHandler, but this returns the user first and last name, not the nickname that the user uses to e.g. write reviews on iTunes.
Thanks

Using fetchUserRecordIDWithCompletionHandler and discoverUserInfoWithUserRecordID is the only way to get information about the current iCloud user.
Besides that you do have to be aware that starting from iOS 9 you wont't get the first and last name anymore only a displayname. For more info see https://developer.apple.com/library/prerelease/ios/documentation/CloudKit/Reference/CKDiscoveredUserInfo_class/index.html#//apple_ref/swift/cl/c:objc(cs)CKDiscoveredUserInfo

Related

How would I be able to uniquely identify a contact in a contact store in a iOS device?

I need someway to uniquely identify a contact in contact store even if the contact is changed.
Is there a way to put code in iOS that is always watching in the background for the contact store to change? That way I can track a contact that I identify with a UUID value and make sure I can always match that specific contact with its UUID value even if the contact changes. If I put it in my app, then the user can close the app, and the app won't receive notifications when the contact store changes? Is there an app extension I can use that would allow me to do this, whether that is the intent of the extension or not?
Perhaps I can use key-value observing. Is it possible to observe the iOS Contacts app or the contacts store of a device using key-value observing? How would I find out? I can't find information on it when I do a search on Google.
I found information about the ABAddressBookRegisterExternalChangeCallback(::_:) function of the Address Book Framework, but that function has been deprecated, and only works with iOS 2.0–9.0. I don't see a function in the Contacts Framework that does what that function does.
Content Added Thursday, March 3, 2022, 12:03 AM:
I need the unique identifier to be saved in a record in a private iCloud database. The objective is to be able to query the database for the record associated with that contact. That would probably mean that the identifier would have to be unique across all iOS devices in existence.Is that so?

CloudKit: can't discover identities

Pretty new to CloudKit. Trying to get all the contacts who are using my app. According to the docs and the tutorials out there I'm calling this:
discoverAllIdentities(completionHandler:)
The issue is that only my user (the one who is logged in on the device where the app is running) is returned. So I did some digging and noticed that if I call this one:
discoverUserIdentity(withPhoneNumber:completionHandler:)
and I use phone number directly the user is returned.
So after more investigation, I figured that the reason I do not get those users is that in my Contacts those users do not have their iCloud email stored. So once I add the email, they are returned by discoverAllIdentities(completionHandler:). So it appears the default implementation of that method is tied to iCloud emails for the discovery instead of phone number.
Is it possible to use phone number for discoverAllIdentities(completionHandler:)? Since, I don't think that as you add a new contact you would record anything but just phone number, so you will be missing to discover all those users.
Any kind of help is highly appreciated.

CloudKit share participant no longer returns name

I'm working on an app that uses CloudKit sharing functionality. The sharing features have been working great, but recently I no longer get the user names back from the CKShare.Participant when a user accepts the sharing request.
Details
I'm using the built-in UICloudSharingController to set up the share, which works and sets up the share properly.
When the invited user accepts the share, the owner gets a notification of the change in the zone and then fetches the CKShare.
The fetched CKShare object has an array of share participants (CKShare.Participant), which has a nameComponents property. I've used this in order to get the first and last name of the participants to display in the UI. This was all working fine until recently.
Now, however, I'm only getting values in nameComponents for the owner of the share. The accepted participants have nil values for the nameComponents.givenName and nameComponents.familyName.
I have not changed anything in this part of my code in some time, so don't think I've caused this. I've tried this on iOS 11, 11.4, 12, 12.1 and all have the issue. This leads me to believe there might have been a change on the server side from Apple.
Note
I am not requesting .userDiscoverability permissions. I have not had to do that in order to get the names once a user accepts. I realize that I can request that and then use CKDiscoverUserIdentitiesOperation to get the names. But I'd rather not as I don't want the dialog, which is confusing for users.
Has anyone seen this change? Or better, yet, does anyone have any suggestions for tracking down the cause or fixing it?
Thanks.

Is there a way to extract user’s full name from HealthKit in Swift?

I am trying to build a fitness app and I would like to build the user’s profile within the app but I would like to make it as quick and easy as possible for the user. I am able to extract the users stats such as height, body mass, birth date etc from HealthKit but is there a way for me to extract the user’s full name since the ios health app has this on it’s profile page.
I have sifted through the documentation, but so far I haven’t found anything.
no there is no api AFAIC.
you can ask for addressbook access and read the 'me' contact
Well you could go through all the contacts in the AddressBook and see if any of them are marked with the owner flag.
Just be aware that doing this will popup the "this app wants access to the address book" message. Also Apple isn't very keen on these kind of things. In the app review guide it is specified that an app can not use personal information without the user's permission.
You will get the username like this:
var username = NSUserName()!
and you can use same user name for your app.
Yeah, I don’t want to meddle with the address book and freak the user out. I’ll probably just ask them to enter their name instead.

Delete user from server if they delete app

Is it possible to delete a user from a server if they delete your app from their phone?
I am using UUID to create users so they do not have to register but I do not want users to delete the app then rejoin and have a new uuid while the old one is still in the database.
Are there any alternatives to using UUID to avoid registering. Apparently UDID which would have been ideal has been deprecated for IOS 6 and upwards.
Please help, thanks in advance.
Alternatively,
You can create a service in App that ping server once a day. if any device didnt respond from long time then delete it from database.
You can't know if user deleted your app or not. So the method you mentioned is not possible.
One-way is, if you are using any advertisement in your app, you will get the advertisement identifier. It's unique for a device, so if user installs your app again, you will get the same advertisement identifier and you can identify the user. But I won't recommend this method, as I can sell my phone at anytime and the new owner can use your app. But he will be considered as old user in this scenario.
So my suggestion is keep a login for individual users. There are a lot of pitfalls in this approach also. You can't identify whether the app is deleted or not. Also same user can create multiple usernames and use it from same device.
You can save DeviceId into database associated with your user and then check if that device is already registered, delete old one and set new UUID. You can get DeviceId like following:
[[UIDevice currentDevice] identifierForVendor].UUIDString;
This will be the same for all your apps(on the appstore) but unique for device
I think that you can't catch delete event with your application.
Also, check this link as well:
Can I know when the user delete my app?
instead of catching a delete event what you can do is store the user info in your database, if the same user tries to join again throw a prompt indicating the user is already present and don't allow him to sign up

Resources