Important! A new Community experience launched on September 26, 2017. Read more about it here or continue to Base Camp.
Vote up!
0 Votes
2 Replies

Share Functionality using Kony Native function API

Lakshmi Vennamaneni on Jul 13, 2017 07:10 EDT

Posted In
Vote up!
0 votes
Vote down!

Attached sample application which contains share functionality for iphone and android.It can be imported in Viz 7.2 or above.

Below is the code snippet thats available in the shared application

  * @function shareAboutAppInAndroid
  * this function is for share or recommend this application to other users
  * this function will be called onClick of the share button
  * end
function shareAboutAppInAndroid(){
  var KonyMain = java.import("");
  var Intent = java.import("android.content.Intent");
  var String=java.import("java.lang.String");
  var intentObject=new Intent(Intent.ACTION_SEND);  
  intentObject.putExtra(Intent.EXTRA_SUBJECT, "Kony Edification");
  //var str = new String("");
  var str =  "Look at this awesome Kony Edification application for aspiring Kony Developers ->";
  intentObject.putExtra(Intent.EXTRA_TEXT, str);  
  var contextObject = KonyMain.getActContext();
  contextObject.startActivity(Intent.createChooser(intentObject, "choose one"));

function shareAboutAppIniPhone(){ 
  var textToShare = "Look at this awesome Kony Edification application for aspiring Kony Developers ->";
  var NSURL = objc.import("NSURL");
  var NSURLObjectLink=NSURL.URLWithString("");
  var shareItems = [textToShare, NSURLObjectLink];
 var UIActivityViewController = objc.import("UIActivityViewController");
  var avcObject=UIActivityViewController.alloc().initWithActivityItemsApplicationActivities(shareItems, undefined);
  //var avcObject=UIActivityViewController.alloc().jsinit();
 //  UIActivityViewController * avc = [[UIActivityViewController alloc] initWithActivityItems:shareItems applicationActivities:nil];
  var UIApplication = objc.import("UIApplication");
  UIApplication.sharedApplication().keyWindow.rootViewController.presentViewControllerAnimatedCompletion(avcObject, true, undefined);
    //self presentViewController:avc animated:YES completion:nil];
  //NSString *textToShare = @"Look at this awesome website for aspiring iOS Developers!";
  //  NSURL *myWebsite = [NSURL URLWithString:@""];
  //  NSArray *objectsToShare = @[textToShare, myWebsite];
  //  UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];


function getDeviceInfoAndShare(){
  //#ifdef android



Replied by: Jul 13, 2017 07:38 EDT
Vote up!
0 votes
Vote down!

Thanks Pavan for your reply.

For iOS, can you please suggest how do I set the subject?  textToShare  is coming in body of the email while sharing..Thanks

Replied by: Sep 12, 2017 00:23 EDT