0

I would like to implement a function to directly share to Sms in the ShareKit Plugin. It have 3 builted-in function to share directly to Facebook, Mail and Twitter. I took a look in plugin code and it seems to me pretty easy, taking as example the function

shareToMail(subject,body);

- (void)shareToMail:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options {
    [SHK setRootViewController:self.viewController];

    SHKItem *item;

    NSString *subject = [arguments objectAtIndex:1];
    NSString *body = [arguments objectAtIndex:2];

    item = [SHKItem text:body];
    item.title = subject;

    [SHKMail shareItem:item];

}

It seems that it takes as input the two parameters passed in (objectAtIndex:1 and objectAtIndex:2) and then it assign them to the item object (item = [SHKItem text:body];) for send it to SHKMail method.

That is what I understood, but I'm really a noob in ObjC, so... can someone give me some advice in how to create a function that call the Sms method? I think it is called SHKTextMessage but once again I'm really not sure about this...

teone
  • 2,153
  • 3
  • 25
  • 49

1 Answers1

0

if someone need this...

In ShareKitPlugin.m add this:

//at the top, near the other import
#import "SHKTextMessage.h"

//somewhere between @implementation ShareKitPlugin and @end
- (void)shareToSms:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options {

    [SHK setRootViewController:self.viewController];

    SHKItem *item;

    NSString *message = [arguments objectAtIndex:1];

    item = [SHKItem text:message];

    [SHKTextMessage shareItem:item];
}

In the ShareKitPlugin.js add:

ShareKitPlugin.prototype.shareToSMS = function( message)
{
    cordova.exec(null, null, "ShareKitPlugin", "shareToSms", [message] );
};

And now you can share trought Sms using this function:

window.plugins.shareKit.shareToSMS(message);
teone
  • 2,153
  • 3
  • 25
  • 49