Reputation: 47344
I'm working on a medical app that may be a subject to HIPAA requirements, and I'm thinking of a good way to uniquely identify multiple users within the app without using names or pictures. The concept of a colored graphics avatar comes to mind, like the one used by StackOverflow.
Is there some sort of a library that I can use for this kind of dynamic graphic creation? I'm interested in getting a UIImage representation of the gravatar.
Part of the requirement of the app may be sending messages to other users, and I think being able to dynamically generate a gravatar from the user id is much better option than worrying about sending/receiving/caching regular user avatars.
Thank you for your thoughts!
Upvotes: 2
Views: 1840
Reputation: 15722
You can find details about generating gravatar images here
If you want to do it from iOS, you'll need a way to generate a hash of the user ID. Here is a category to add an MD5 hashing method to the NSString class.
If you add the NSString category at the link above to your project, you can then hash the user ID and build a url that will generate a unique gravatar image for your user like this:
int userID = 123456;
NSString *hashedUserID = [[NSString stringWithFormat:@"%i", userID] MD5];
NSString *gravatarURLString = [NSString stringWithFormat:@"http://www.gravatar.com/avatar/%@?d=identicon", hashedUserID];
NSURL *gravatarURL = [NSURL URLWithString:gravatarURLString];
Then you can create NSURLRequest with that URL to request the image and display it in your app.
Upvotes: 3