Direct Sharing via SMS/Email

iOS

To use email and SMS in your iOS apps, you must add the MessageUI framework to your project. As the MessageUI framework is not available on all iOS devices and versions, you must designate the framework as “weak-linked.” Instructions for adding frameworks in Xcode 4 can be found in Apple’s iOS Developer Documentation.

Not all iOS devices have the ability to share through email or SMS, so designating the MessageUI.framework as weak-linked allows the library to dynamically detect the functionality of the device and allow the user the option to share only if email or SMS are available, as shown in Figures 1 through 3. (The library detects if the device is not capable of sending an email or SMS, and will not display the option(s) to the user.)

To share with email or SMS, create a JREmailObject or JRSmsObject, populate the object’s fields, and add the object to the email or SMS property in your JRActivityObject. When the user chooses to share your activity through email or SMS, your application sends the selected content to the MFMailComposeViewController or MFMessageComposeViewController class.

Email

Create a JREmailObject and populate the fields of the object:

JREmailObject *email =
 [JREmailObject emailObjectWithSubject:@"Check out this article from the Janrain Blog!"
                        andMessageBody:@"
"
                                         "I found this article on Janrain's Blog,"
                                         "and I thought you might be interested!"
                                         "
"
          "<a href='http://www.janrain.com/blogs/social-login-iphone-janrain-engage'>"
                                         "Click here to read it.</a>"
                                         "
"
                                         "Learn more at <a href='http://janrain.com'>"
                                         "http://janrain.com</a>
"
                                         "
"
                                isHtml:YES
                  andUrlsToBeShortened:nil];

Add the object* to the your JRActivityObject and pass it to the library:

JRActivityObject *activity =
     [JRActivityObject activityObjectWithAction:@"loves Janrain."
                                         andUrl:@"http://www.janrain.com"];

activity.email = email;

[jrEngage showSocialPublishingDialogWithActivity:activity];

SMS

Create a JRSmsObject and populate the fields of the object:

JRSmsObject *sms =
 [JRSmsObject smsObjectWithMessage:
                 [NSString stringWithFormat:
                   @"Check out this article from the Janrain Blog! %@",
                   @"http://www.janrain.com/blogs/social-login-iphone-janrain-engage"]
              andUrlsToBeShortened:nil];

Add the object* to your <tt>JRActivityObject</tt> and pass it to the library:
JRActivityObject *activity =
     [JRActivityObject activityObjectWithAction:@"loves Janrain."
                                         andUrl:@"http://www.janrain.com"];

activity.sms = sms;

[jrEngage showSocialPublishingDialogWithActivity:activity];

* If you do not supply a JREmailObject or JRSmsObject to the JRActivityObject, the option of sharing by email or SMS (respectively) will not be available to the user. If you do supply an email or SMS object to the activity, but the device does not have this capability, the option will not be available to the user as well.