In Openfire users are created with a "Username" (which is used as the basis for the JID) and a descriptive "Name". How does one retrieve the Name for a given JID in XMPP? I'm using XMPPFramework.
You may retrieve a user's Display Name using his JID from XMPPUserCoreDataStorageObject like this:
XMPPJID *userJID = #"shakespeare";
XMPPUserCoreDataStorageObject *user = [[[self appDelegate] xmppRosterStorage]
userForJID:userJID
xmppStream:[[self appDelegate] xmppStream]
managedObjectContext:[[self appDelegate] managedObjectContext_roster]];
NSString *userDisplayName = user.displayName;
Are you using the CoreData portion of the roster when setting up the XMPPFramework? You can get the user via the JID from the storage class that is set (for example, the XMPPRosterCoreDataStorage).
From here, you can get the user stored from the roster request via the storage class such as:
[xmppStorage userForJID:jid ...]
and from here, the resulting object (XMPPUserCoreDataStorageObject) has fields for 'nickname', 'displayName', etc. Some information can also be obtained from the associated vCard for that JID.
Related
I am integrating Apple Pay using PKPaymentAuthorizationViewController and its delegate methods.
When user changes the Address the below delegate method gets triggered:
- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectShippingContact:(PKContact *)contact completion:(void (^)(PKPaymentAuthorizationStatus status, NSArray<PKShippingMethod *> *shippingMethods, NSArray<PKPaymentSummaryItem *> *summaryItems))completion
When I try to access the Phone number from 'contact' it is always empty also the name (given name, family name, etc.) are also empty. But the selected shipping contact has all the information like name, phone number, postal address.
PKPaymentRequest *pkPaymentRequest = [[PKPaymentRequest alloc] init];
pkPaymentRequest.merchantIdentifier = merchantId;
pkPaymentRequest.supportedNetworks = #[PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa, PKPaymentNetworkDiscover];
pkPaymentRequest.merchantCapabilities = PKMerchantCapability3DS;
pkPaymentRequest.countryCode = #"US";
pkPaymentRequest.currencyCode = #"USD";
pkPaymentRequest.requiredShippingContactFields = [NSSet setWithArray:#[PKContactFieldPostalAddress, PKContactFieldName, PKContactFieldPhoneNumber]];
This is address I have been using for now:
Find the debugging info in below screenshots which shows the PKContact object 'contact' is missing the required information.
I have found solution, hope this may help out someone like me.
https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypayment/1916097-shippingcontact
Above link gave me hints that I can't get the complete address info in the delegate method 'didSelectShippingContact' instead it will be provided only after the payment is authorized by user using Touch ID, Face ID, or Passcode in the delegate method 'didAuthorizePayment'. Here we have an object of PKPayment (payment), this object consists all the Address/Contact Fields that I require to process further to complete the Payment Transaction.
This is my code in Firebase.
//Create a reference to a Firebase database URL
Firebase *savedRef2 = [[Firebase alloc] initWithUrl:#"https://example.firebaseio.com/Location_Coordinates"];
// Write data to Firebase
Firebase *postRef2 = [savedRef2 childByAppendingPath: #"LOCATION DATA"];
NSDictionary *post1 = #{
#"DATE": dateString,
#"Lat": #(location.coordinate.latitude),
#"Long": #(location.coordinate.longitude),
#"USER": name,
};
Firebase *post1Ref = [postRef2 childByAutoId];
[post1Ref setValue: post1];
When a user clicks save on the app, the data is saved to my Firebase data base but it keeps saving as a new object right under the previous saved. How can I make it so it saves once and the rest that are saved are childs of that first saved data?
This is a picture Current saved data for coordinates. of how it keeps saving and I don't want it like this. How can I make it so it looks like this 2. I am saving coordinates of users but it keeps recreating a new 'childByAutoId' string and I just want the saved data to fall under the 1st 'childByAutoId' string and not to keep creating new ID's so each users coordinates fall under one ID each time it is saved.
UPDATE:
I have different users submitting data and in that data are coordinates. I want that same users data to be created ONLY under ONE node using 'childByAutoID' and the rest of the data (coordinates) will be under that. The way it is set up right now is that MULTIPLE nodes (childByAutoId) are being logged to Firebase and it makes it hard for me to read it so that is why I want ONE node (childByAutoId) created first and the rest fall under that EACH time someone clicks save.
This is how I currently have it. And this is how I want it
Super easy!
When a user authenticates the auth Firebase variable is populated with their user id.
In general if you are storing information about users you would store that data or associate that data with their uid.
So, when you want to store data for each user, store it in a node where the parent is their uid
Location_Coordinates
LOCATION DATA
uid_0
childByAutoId
childByAutoId
uid_1
childByAutoId
childByAutoId
then to create the reference
Firebase *rootRef = [[Firebase alloc] initWithUrl:#"https://example.firebaseio.com];
Firebase *locCoordsRef = [rootRef childByAppendingPath("Location_Coordinates");
Firebase *locDataRef = [locCoordsRef childByAppendingPath("LOCATION DATA"];
NSString *uid = rootRef.authData.uid
Firebase *thisUserRef = [locDataRef childByAppendingPath(uid)];
NSDictionary *userDataDict = #{
#"DATE": dateString,
#"Lat": #(location.coordinate.latitude),
#"Long": #(location.coordinate.longitude),
#"USER": name,
};
Firebase *dataRef = [thisUserRef childByAutoId];
[dataRef setValue: userDataDict];
I'm using the the PFLogInViewController of the ParseUI framework. I have two questions related to emails with regards to Facebook Login within the framework:
1) When signing up via Facebook, I see that the email field of my new user is 'undefined.' How can I obtain the user's email address?
2) If I am able to obtain the email address, does parse's application setting of 'emailVerified' still send a verification email to the user upon Facebook signup? If not, how can this be done?
Thanks.
In order to read the user's email address you'll need to add email to your array of Facebook permissions you're requesting. Look at the Parse tutorial on this https://www.parse.com/tutorials/login-and-signup-views#properties
In your case, you'll want to add #"email" like this:
[logInViewController setFacebookPermissions:[NSArray arrayWithObjects:#"friends_about_me", #"email", nil]];
Then when you are requesting the user information from Facebook, you will be able to access the user's email address:
FBRequest *request = [FBRequest requestForMe];
[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
// Now you can access user's email
NSString *email = result[#"email"];
if (email) {
// Save it to your email field in Parse
}
}
}];
Regarding part 2 of your question, I'm not as familiar with the email validation functionality that Parse supports, but looking at this (admittedly old) response https://www.parse.com/questions/email-verification-emails-going-out-to-facebook-users it appears that Parse will validate email addresses even when the user logs in with Facebook.
In my application utilizing XMPPFramework, I have a login page to authenticate one user.
Once logged in, I wish to show the displayName of the user in my status page. The displayName is a NSString in XMPPUserCoreDataStorageObject.
The following line returns me the XMPPJID of my currently logged-in user. I thought this would be useful to check against my roster to get his displayName.
[[[self appDelegate] xmppStream] myJID];
However, placing the above in the code below returns me a null.
XMPPUserCoreDataStorageObject *user = [[[self appDelegate] xmppRosterStorage]
userForJID:[[[self appDelegate] xmppStream] myJID]
xmppStream:[[self appDelegate] xmppStream]
managedObjectContext:[[self appDelegate] managedObjectContext_roster]];
Appreciate any advice on how to go about retrieving the displayName of the current user.
As vitalyster mentioned in the comment above, there is no way to retrieve my own display name if I am logged in.
To verify that, I went to my Openfire server settings.
In Users/Groups > User Summary > KeithOYS > Roster, there is no same user called KeithOYS in the roster list.
Same concept applies for every other users.
In a nutshell, every user has all other users in their Roster (as long as they are classified under the same Group), all except himself.
I have got the user name of logged in user with following code.
XMPPJID *myjid = [[[self appDelegate]xmppStream]myJID];
NSString *userName = [NSString stringWithFormat:#"%#",myjid.user];
Hope it will help someone.
When I access to the Facebook Account using ACAccountStore to get an ACAccount object I noticed that for some profiles the ACAccount.username give me the Facebook email but for other profiles give me the nickname... How is possible that the same property contains different value ?
This drive me crazy...
Yes, it's weird for me too.
But I can get the email from properties field like below:
NSString *email = [[account valueForKey:#"properties"] objectForKey:#"ACUIDisplayUsername"];