Screen capture not working anymore on iOS11


I had my screen capture code working fine till I moved to iOS11 (using the old Screenshot plugin) - user clicks SHARE button, an image is captured (here is where my problem occurs), then the Social Share plugin (from TJ Van Toll) sends it to Facebook (or any other external app).

Like I said, before iOS11 update, everything worked fine. Now, the image is not generated, reason why the app crashes when the button is pressed (everything works fine if I change the code and force to use an image from the resources folder).

I am assuming there are changes in iOS and/or {N} APIs (but I couldn’t find anything/anywhere).


var imageSource = require("image-source");
exports.getImage = function(view) {
    if (view.ios) {
        UIGraphicsBeginImageContextWithOptions(view.ios.frame.size, false, 0);
        view.ios.drawViewHierarchyInRectAfterScreenUpdates(CGRectMake(0, 0, view.ios.frame.size.width, view.ios.frame.size.height), true);
        var imageFromCurrentImageContext = UIGraphicsGetImageFromCurrentImageContext();
        console.log("Image returned: "+imageFromCurrentImageContext)
        return imageSource.fromData(UIImagePNGRepresentation(imageFromCurrentImageContext));
    } else if ( {;
        var bmp =;;
        var source = new imageSource.ImageSource();
        return source;
    return undefined;


var frameModule = require("ui/frame");
var utilsModule = require("utils/utils");
function share(thingsToShare, index) {
                var activityController = UIActivityViewController.alloc()
                                .initWithActivityItemsApplicationActivities(thingsToShare, null);
                var presentViewController = activityController.popoverPresentationController;
                if (presentViewController) {
                                var page = frameModule.topmost().currentPage;
                                if (page && page.ios.navigationItem.rightBarButtonItems &&
                                                page.ios.navigationItem.rightBarButtonItems.count > 0) {
                                                presentViewController.barButtonItem = page.ios.navigationItem.rightBarButtonItems[0];
                                } else {
                                                presentViewController.sourceView = page.ios.view;
                utilsModule.ios.getter(UIApplication, UIApplication.sharedApplication)
                                .presentViewControllerAnimatedCompletion(activityController, true, null);
module.exports = {
                shareImage: function(image) {
                shareText: function(text) {
                shareUrl: function(url, text) {
                                share([NSURL.URLWithString(url), text]);


var image = require("ui/image");
var plugin = require("nativescript-screenshot");
var fs = require("file-system");
//Share plugin
var SocialShare = require("nativescript-social-share");
var imageSourceModule = require("image-source")
exports.onShare = function(args) {
    //take screenshot
    var img = new image.Image();
    img.imageSource = plugin.getImage("printMe"));
    var folder = fs.knownFolders.documents().path;
    var d = new Date();
    var day = d.getDate()
    var month = d.getMonth() + 1
    var fileName = "Test"+day+"_"+month+".png"
    var path = fs.path.join(folder, fileName);
    var image2 = imageSourceModule.fromFile(path);
    SocialShare.shareImage(image2, "PPG Finder");

Any ideas on how to address/fix it? I can’t update my app because it will break a functionality that works on versions prior to iOS11.


By the way, this is the crash error from the console:
Oct 2 13:23:44 Alexs-MacBook-Pro-2[31362] (UIKitApplication:com.asouza.ppgFinder[0xd554][31388][39902]): Service exited due to signal: Segmentation fault: 11 sent by exc handler[0]
Oct 2 13:28:26 Alexs-MacBook-Pro-2 diagnosticd[34560]: dispatch_io_write error: 32 (Broken pipe)
Oct 2 13:28:26 Alexs-MacBook-Pro-2 diagnosticd[34560]: reflect channel created for fd 5
Oct 2 13:28:46 Alexs-MacBook-Pro-2 budd[39961]: objc[39961]: Class BYBuddyDaemonCloudSyncClient is implemented in both /Applications/ (0x10a2af820) and /Applications/ (0x109d981f8). One of the two will be used. Which one is undefined.