Sub Process_Globals
Private myPage As Page
End Sub
#IF OBJC
#define SCREEN_WIDTH ((([UIApplication sharedApplication].statusBarOrientation ==UIInterfaceOrientationPortrait)||([UIApplication sharedApplication].statusBarOrientation ==UIInterfaceOrientationPortraitUpsideDown))?[[UIScreen mainScreen] bounds].size.width :[[UIScreen mainScreen] bounds].size.height)
#define SCREEN_HEIGHT ((([UIApplication sharedApplication].statusBarOrientation ==UIInterfaceOrientationPortrait)||([UIApplication sharedApplication].statusBarOrientation ==UIInterfaceOrientationPortraitUpsideDown))?[[UIScreen mainScreen] bounds].size.height :[[UIScreen mainScreen] bounds].size.width)
- (void)share2SocialMedia:(NSString *)txt :(NSString *)theurl :(NSString *)theimg :(UIView *)SBview
{
//NSString *text = @"How to add Facebook and Twitter sharing to an iOS app";
NSString *text = txt;
//NSURL *url = [NSURL URLWithString:@"http://roadfiresoftware.com/2014/02/how-to-add-facebook-and-twitter-sharing-to-an-ios-app/"];
NSURL *url = [NSURL URLWithString:theurl];
//UIImage *image = [UIImage imageNamed:@"roadfire-icon-square-200"];
UIImage *image;
if([theimg hasPrefix:@"http://"] || [theimg hasPrefix:@"https://"] ) {
image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:theimg]]];
} else {
image = [UIImage imageNamed:theimg];
}
UIActivityViewController *controller =
[[UIActivityViewController alloc]
initWithActivityItems:@[text, url, image]
applicationActivities:nil];
controller.excludedActivityTypes = @[UIActivityTypePostToWeibo,
UIActivityTypeMessage,
UIActivityTypeMail,
UIActivityTypePrint,
UIActivityTypeCopyToPasteboard,
UIActivityTypeAssignToContact,
UIActivityTypeSaveToCameraRoll,
UIActivityTypeAddToReadingList,
UIActivityTypePostToFlickr,
UIActivityTypePostToVimeo,
UIActivityTypePostToTencentWeibo,
UIActivityTypeAirDrop];
[controller setCompletionHandler:^(NSString*activityType, BOOL completed) {
// Raise the event for B4i
if (completed) {
[self.bi raiseEvent:nil event:@"activity_completed::" params:@[@((BOOL)completed),(activityType)]];
} else {
NSString *activity = @"";
[self.bi raiseEvent:nil event:@"activity_completed::" params:@[@((BOOL)completed),(activity)]];
}
}];
//if iPhone
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
[(self._mypage).object presentViewController:controller animated:YES completion:nil];
} else { //if iPad
// Change Rect to position Popover
UIPopoverController *popup = [[UIPopoverController alloc] initWithContentViewController:controller];
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
UIView *topView = window.rootViewController.view;
[popup presentPopoverFromRect:CGRectMake(SBview.Left + SBview.Width/2, SBview.Top+SBview.Height, 0, SBview.Height)inView:topView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
}
#End If
Sub activity_completed(status As Boolean, T As String)
'If Main.DEBUG Then
' Utils.Log_("onSharingDone: Status = " & status & " - Type: " & T & " - Will look for callback: ShareModule_SharingCompleted in " & myPage.Title)
'End If
' If SubExists(myPage, "ShareModule_SharingCompleted", 2) = True Then
' CallSub3(myPage, "ShareModule_SharingCompleted", status, T)
' End If
End Sub
Sub ShareToSocialMedia(p As Page, txt As String, theURL As String, imageFileOrURL As String, shareButton As Button)
myPage = p
Dim v As View = shareButton
Dim NativeMe As NativeObject = Me
NativeMe.RunMethod("share2SocialMedia::::", Array As Object(txt, theURL, imageFileOrURL, v))
End Sub