Passing value from CloudKit app to another user - objective-c

I am new in CloudKit and just now analyzing CloudKitAtlas from Developer Library.
I create app where i want to "share" data to another user of the same app.
I have CKContainer in private database, where user put all his created dictionaries. Now i want to give him possibility to share some part of his data to another user (create public containerWithIdentifier) . I know is possible to check every email address from address book and get result who have that app installed. So user can choose who will be able to see his data.
The question is how to tell another user app "look to that CKContainer on my shared data" :)
Anyone already do something like this?

You can list all users from your addresbook that has the app installed using the container discoverAllContactUserInfosWithCompletionHandler method. It will return an array from which you can get an recordID. If you want to share something with one of those users, then create a record where you put that ID in a to field. On startup of your app you will have created a subscription with a predicate that looks for that TO field and compare that to your own user recordId. So if a record is created with your ID in the TO field, then you will receive a notification. Whatever you want to send to an other user must be in the public database. I am working on something like this. The code can be found at https://github.com/evermeer/EVCloudKitDao (work in progress)

Check the CKContainer.h in CloudKit framework, they discover people in your contacts by their email address. If that email address in contacts is not the email address to login apple id (or icloud account?), I guess it can not match.
typedef NS_OPTIONS(NSUInteger, CKApplicationPermissions) {
/* Allows the user's record in CloudKit to be discoverable via the user's email address */
CKApplicationPermissionUserDiscoverability = 1 << 0,
} NS_AVAILABLE(10_10, 8_0);

Related

How do you store user information in firestore if they don't have an account?

I am trying to create an app using firebase auth and firestore where new users can be invited via email to work on a project. The problem is, I do not know the best way to store the temporary user project permissions before they have a uid. I want the user that got invited via email to get access to the project upon opening the link sent to them.
I had tried two different ways
Having a sub collection doc for every user in the project
/project/{projectId}/users/{userId}
When a new user is invited, the userId was set to their email, having a cloud function that triggered when a new user was created to send the invite email to the user. Once the user opened the link, it deleted their user document and a cloud function ran that created a new doc with the users id now that they had once since they were authenticated.
This worked, but left a 10 second period where the user can't interact with the project because the cloud function for making the new user doc is running. Also it just seemed like a bad way to do it.
Having a single document with all of the user information
/project/{projectId}/users/users
users:{
roles: {
users_id: 'admin',
new_user_email: 'admin',
}
}
This one I was not able to get to work as firestore does not let you create a key with a period in it, but if there was a way around this, it would work as well. I had also set up firestore security rules which made it so they could only edit fields where the key was there uid or their email if they were not an editor/admin.
Consider creating an anonymous account in Firebase Authentication first, which requires no input from the user. It will receive a UID that you can use to store data for that account. Then, you can convert that account to a normal account after the signup or login succeeds.
Since you didn't say which mobile platform you're using, I linked you to the web docs, but the procedure is generally the same for each one.

web2py veiwing auth() itmes

Hi I am working on a web2py project.
I use auth object to create login feature
And using the following code
auth.settings.extra_fields['auth_user']= [Field('address')]
So whenever, an user sign up for an account, the person need to put address.
What I would like to do is display the address in default/index.html when the user login to my application.(the user can view his own address only, not the others)
Do I need to deal with db.auth_user??
I have no clue...
Can you help me?
Thank you.
If the user is logged in, the entire user record is available in auth.user (which will have a value of None if the user is not logged in). So, to display the address in a view:
{{=auth.user.address}}
You could also retrieve the user record from the database via db.auth_user(id) or db(db.auth_user.id == id).select().first(), but using auth.user is more efficient, as it is stored in the session and therefore does not require a database query.

Reclaiming a lost Facebook app

I am a new member of a team at my company reviving a legacy product that had Facebook integration, and we wish to continue developing the Facebook side of things, but we can't seem to find the credentials for logging into the app, or even who has access to it.
The app we are trying to recover is "HaloMobile". One thing to note though is the app name on posts is no longer a link. Does this mean the app has been disabled somehow?
I'm obviously not asking for credentials. At this point I'm just trying to "find" the app and possibly determine who is currently assigned as the administrator role, or what my options are. If there is an email address associated with the app, perhaps we can send a transfer request to that email?
If you could get retrieve two piece of information from your code-base, which are App ID and App Secret then you can retrieve the list of roles assigned in app using the following end point,
https://graph.facebook.com/<App_ID>/roles?access_token=<App_ID>|<App_Secret>
And once you know the role, along with the user Ids of the user assigned to it, you can move forward to recover the App by contacting him.
Also, you might want to give this documentation about Application a look, which lists out various fields you can retrieve for getting the required information to get access to your application back, like user_support_email
https://graph.facebook.com/<App_ID>?
fields=name,description,creator_uid,user_support_email
&access_token=<App_ID>|<App_Secret>

How to save user data in an iPhone login type app

Im developing an iPhone app with user logging design and i am trying to understand how to save user data and app state for each user in the same iPhone.
For example suppose my app flow is as follow:
1. user log in.
2. app gets the user friends list from core date and present it.
3. in the background the app fetch the user friend list from a server and update core data.
Now suppose there are two users that simultaneity uses the app with the same iPhone
how can i know witch data to load from core data to each user? haw can i know witch app state to return to?
First of all, it seems important to pose the question of why you are trying to do this in the first place. As I'm sure you have noticed, Apple designed the iPhone to be a single user device. This is why you don't see their apps (and generally apps from 3rd parties as well) allowing multiple users.
That said, if you are absolutely sure you want to do this, then you clearly need to give the user some ability to change user accounts. You're never going to know when one person is using the phone over another, so you have to provide the ability to switch users similarly to how fast user switching works in OS X.
Anyway, you probably need to start by creating an additional Core Data entity called "User". That entity should contain information about each user (name, nickname, photo, etc). Then you need to create a relationship from the "User" entity to whatever entities you are using to store your friends list.
You'll need to decide what the behavior of the app will be. Will the current user automatically be logged out when the app quits? Hard to say as you don't know who is going to use the app next.
I would create a core data entity for users and link the entries in it with the friend list entries. Therefore every user should have a unique identifier. Also in your friendlist entity there should be a key like "userId" to hold the reference to the user.

facebook one-login authentication

Im adding facebook one-login to my website. Just wanted to get some feedback from people who have already implemented it.
At the moment im allowing user to login to my site using fb:login, providing they have a valid account on fb and login successfully, if the same email address thats returned from fb matches my email address I hold in my own database, they will automatically be logged in to my site.
The problem I have is, im finding hard having just the email as my main authentication between the user and the my site. For those who have already implmented this, could you please share some of you loggic (theory) on how you autenticate the user when you're logging them onto your site.
I had the same problem than you. I had users in my database with their name and email address and I wanted to add the Facebook connect plugin.
Now, on the login page, I let users choose between standard and Facebook login. If one choose Facbook login I retrieve his Facebook ID with the Facebook PHP SDK (see on github) :
$facebook = new Facebook(...);
$id = $facebook->getUser();
If I have this Facebook ID in my records, I log the user in.
If not, I retrieve his email adress :
$profile = $facebook->api('/me');
$email = $profile['email'];
If I have this email in my database, I store the facebook ID in that record (for the next time) and I log the user in.
If not, I create a new record with the Facebook ID and the email. After that, the user can set a password in his settings to be able to log in with the standard login (without Facebook).
You may want to check the example of the Facebook PHP SDK out to better understand how the flow works.
Hope that helps.
I have also done this. I have now understood that you do you want to match the email address that if user changes his email address you want to update it. Its simple solution is that store the user information in your database. What I have done, I store the user profile id returned by the facebook as user name and by converting into md5 I store the same profile ID as password and email adress returned by the user. Now every facebook user has its unique id in my database. Whenever user comes to my site and logins with facebook, There are two cases
1- I compare the profile id with my database and if record found I always update the email address in that particular field returned by facebook.. Now I can have the latest email address of the user. 2- if the user is not in my database then I insert the record by applying the above method.
Hope it will help you