-
-
Save gabrielecirulli/884f79e668401d5dc7d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- a/src/ios/Screenshot.m | |
+++ b/src/ios/Screenshot.m | |
@@ -11,6 +11,7 @@ | |
#import <Cordova/CDV.h> | |
#import "Screenshot.h" | |
+#import "AssetsLibrary/AssetsLibrary.h"; | |
@implementation Screenshot | |
@@ -25,7 +26,7 @@ | |
// statusBarOrientation is more reliable than UIDevice.orientation | |
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; | |
- if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) | |
+ if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) | |
// landscape check | |
imageRect = CGRectMake(0, 0, CGRectGetHeight(screenRect), CGRectGetWidth(screenRect)); | |
} else { | |
@@ -48,7 +49,19 @@ | |
[webView.layer renderInContext:ctx]; | |
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); | |
- UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil); | |
+ | |
+ ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; | |
+ | |
+ // Request to save the image to camera roll | |
+ [library writeImageToSavedPhotosAlbum:[image CGImage] orientation:(ALAssetOrientation)[image imageOrientation] | |
+ if (error) { | |
+ // The callback should receive the error | |
+ } else { | |
+ // The callback should receive the response json object with the path | |
+ } | |
+ }]; | |
+ [library release]; | |
+ | |
UIGraphicsEndImageContext(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment