Jailbreak console app save photo - objective-c

I've created a console app for iOS using iOSOpenDev which is trying to write to the camera roll / saved photos. I've granted permission to access the photo library using entitlements (and checked that the access been granted). But I can't seem to get any form of image to save (using any examples online).
I'm using the following method to save the image:
UIImage *test = [UIImage imageNamed:#"test.png"];
UIImageWriteToSavedPhotosAlbum(test,nil,nil,nil);
(when supplied) it never returns any error messages and doesn't write successfully.
I've also tried:
[library writeImageToSavedPhotosAlbum:.....]
With no better results. I think that this is a problem relating to using UIkit from a console app, rather than my implementation of the save methods?
I'm trying to run on iOS 7 & 8 ideally

Related

How to get all PHAssets from MacOS's Photo Library

I want to parse all images from my MacOS Photos Library, using PHAsset. However all examples I find are only working for iOS, like the one below, where the last line, which retrieves the assets is not available on macos framework:
NSMutableArray *photos = [[NSMutableArray alloc] init];
PHFetchOptions *allPhotosOptions = [[PHFetchOptions alloc] init];
allPhotosOptions.sortDescriptors = #[[NSSortDescriptor sortDescriptorWithKey:#"creationDate" ascending:YES]];
// Below compilation error as fetchAssetsWithMediaType is only on iOS framework
PHFetchResult *allPhotos = [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeImage options:allPhotosOptions];
What fetchAssets command should I use on MacOS (version 10.13), or is there another way to do so ?
The Photos framework — or at least, the main subset of that framework, which provides apps with read/write access to the entire Photos library — is not available in macOS.
Photos and PhotosUI are present in macOS, but only in support of specific app-extension features:
Photo Editing extensions. The user invokes these from the Photos app while in Edit mode for a single asset, and it provides direct access to the photo/video data for that asset, so it doesn’t even use the PHAsset class.
Photo Project extensions. These involve collections of assets and selectively loading data for each, so more of the PHAsset/PHImageManager system is present. However, it’s still a reduced subset compared to iOS (only what’s needed for a project extension, like fetching the assets in that project), and it’s accessible only to app extensions, not standalone apps.
If you’d like the full Photos framework on macOS, your best bet is to file a feature request with Apple.
As of macOS 10.15 Catalina, the Photos and PhotosUI frameworks are now available on the Mac, for both Catalyst and AppKit apps. So you should be able to transfer almost all iOS code that uses PhotoKit over to your Mac app now, as long as it has 10.15 as a minimum system requirement.

iOS app files that the user can download from the app

The idea is that i will create a file in the app and store some data in it.
I want for the end user to be able to download that file from the iOS device to his mac/pc.
Is this somehow possible? Where should i put the file for the user to be able to download it via itunes?
Here is good tutorial you can use:
Tutorial
It is important to know, that in iOS, when your user needs to create file, you do not need to care where to save it.
Another possibility for you might be to avoid saving data as file. For example, if your data is picture:
UIImage send to email

UIVideoAtPathIsCompatibleWithSavedPhotosAlbum returns false when deploying on the iPhone

One of my app's features is to download a mp4 file and store it to the local phone album.
I have tried several approaches since and the result is always the same, it worked on the simulator but not on the actual iPhone. Xcode is version 5.0.1, iPhone 4.
Below is the code I applied on the last attempt before posted here using ASIHttpRequest library and the result is still the same, it worked on the simulator but not the phone itself.
download:
ASIHTTPRequest* request = [ASIHTTPRequest requestWithURL:url]; // url is the address to the mp4 file
NSString* filePath = [NSString stringWithFormat:#"%#%#", NSTemporaryDirectory(), filename]; //filename is the file I save to, e.g. xxx.mp4
[request setDownloadDestinationPath:filePath];
[request setDelegate:self];
[request setDidFinishSelector:#selector[ASIRequestDone:)];
[request setDidFailSelector:#select[ASIRequestFail:)];
when download is finished, save it to the photo album (in ASIRequestDone delegate)
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(filePath))
{
//comes to here when running in simulators
UISaveVideoAtPathToSavedPhotosAlbum(filePath, self, #selector(video:didFinishSavingWithError:cotextInfo:),nil);
}
else
{
//always comes to here when running on the actual iPhone.
}
I have checked the pathFile it's this
/private/var/mobile/Applications/xxxxxxxxxx/tmp/xxxxx.mp4
which is alright to me. What I am not getting is it works fine when running on Simulator and hence I am stuck not sure what to do next. (I have also checked the permission accessing the the photo albums and yes the app has it).
I also tried to removed the compatible checking and went straight into the method UISaveVideoAtPathToSavedPhotosAlbum, it didn't throw any error on delegate didFinishSavingWithError. however, the video didn't show up on the photo album either, I am guessing it's correct as the phone seems to say that video is not compatible to be shown on the album. Again, my issue is that it does work on the simulator and how do I fix this on the actual iphone, e.g. why it thinks the video is not compatible? is something to do with the mp4 itself or is it something to do during the download step? What could I do next to resolve the issue? (ps. I also have control over the mp4 files, is there a list of mp4 compatibility on the iphone that you know? I am thinking perhaps it's genuine that the file is not compatible on the phone (but on the simulator!?))
Found the answer to my question and I hope it could help out someone who suffers from the same issue. Turns out video resolution is the factor between the simulator and the actual phone when it comes to store video to the gallery; to be specific:
Compatibility checking UIVideoAtPathIsCompatibleWithSavedPhotosAlbum would FAIL on the actual phone but would PASS on the simulator given a sample clip capturrd as 1080p. I came cross this link a week after my post with luck.
"What video formats are compatible with the assets library?"
And I did the experiment similar to that by capturing 720p video clips instead and all files were able to be saved to the gallery. Weird thing is that the actual iphone can play the HLS stream at 1080p; howeve it won't store clips unless they are 720p, not to me anyway. And the misleading bit is that the simulator can actually do 1080p.

How can I add binary image to photo gallery using objective-c

I am creating app to display image from web services on iPad
I use FGallery to create photo gallery on my app and I retrieve binary image form web services and convert it to UIImage.
How can I add images to FGallery?
I am hoping that someone out there might have a solution that can perform this task, or if anyone could point me in the right direction, I would really appreciate it!
FGallery is current written to load images from the application bundle or web server via URL. Because you cannot change the application bundle at run-time, you will need to change FGallery to read images from <Application_Home>/Documents/ folder. Once that is accomplished, you will then save your new UIImage to the application documents folder and update the NSArray *localImages in the RootViewController.

update page in our app that get data from the net

I'm about to release my app (based on the Cocos2d game engine) on the iOS App Store, but I'm worried about updating it - I don't have a facility to send my own data to the app outside of the App Store update process.
I'd like to be able to tell my users "hey, an updated version of this app is available!" or to send other similar messages to users that they'll see when they open the app. For example, I'd like to be able to show the user a "there is a new level available for download" message on the app's launch screen.
How could I add a "remote" scene like this, that will only appear when I want it to, outside of the App Store update process? I'm pretty sure that I need a server that I can have my app talk to - is that right? How complicated would it be to set this up? Are there any guides available?
It's very easy with pictures and text, but DON'T block the user until you've got the response from your server. For example you could write a small python script and run it on Google's cloud service App Engine.
Your 'server side' could be as simple as a piece of text at a given url.
Your client side code will likely want to use NSURLConnection to query the server.
I have a method on my web server that returns JSON with the latest version, and then code in the app as follows:
NSNumber *serverVersion = [dict objectForKey:#"version"];
NSNumber *currentVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:#"CFBundleShortVersionString"];
if ([serverVersion intValue] > [currentVersion intValue]) {
// Out of date
}
Which simply checks the version returned in the JSON dictionary against that in the Info.plist. Where I have my comment block you could have your line of code to display your update scene.