This is a Parse Cloud Code file for adding a friends relationship for both users.
Usually with Cloud Code, you can only make changes to the currently logged in user.
However, this Parse Cloud Code file utilizes the Master Key. This allows a friends relationship to be added for both the currently logged in user, and the other user.
Instructions:
Simply replace INSERT-RELATION-KEY-HERE with the name of your relation key in Parse, and upload your new Cloude Code file.
If you would like to see how to implement this Parse Cloud Code functionality in a native iOS app written in Objective-C, then be sure to check out my parse-friends-ios repo.
If you have any questions or just want to get in touch, feel free to contact me via Twitter or email.