-
-
Save camdenfullmer/b287f634acd089f4b92f to your computer and use it in GitHub Desktop.
@implementation CMFWallpaper | |
+ (void)setImage:(UIImage *)image { | |
NSAssert([PHPhotoLibrary authorizationStatus] == PHAuthorizationStatusAuthorized, @"access to photos is needed to set the wallpaper"); | |
NSString *path; | |
#if TARGET_OS_SIMULATOR | |
path = @"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibrary.framework"; | |
#else | |
path = @"/System/Library/PrivateFrameworks/PhotoLibrary.framework"; | |
#endif | |
NSBundle *bundle = [NSBundle bundleWithPath:path]; | |
[bundle load]; | |
#pragma clang diagnostic push | |
#pragma clang diagnostic ignored "-Wundeclared-selector" | |
// Instantiate the controller. | |
id class = NSClassFromString(@"PLStaticWallpaperImageViewController"); | |
id controller = [[class alloc] performSelector:@selector(initWithUIImage:) withObject:image]; | |
// Select what wallpaper mode. | |
// 0 - Both lock screen and home screen. | |
// 1 - Home screen only. | |
// 2 - Lock screen only. | |
int wallpaperMode = 0; | |
[controller setValue:@(wallpaperMode) forKey:@"wallpaperMode"]; | |
// Tell the controller to save the data. | |
[controller setValue:@YES forKey:@"saveWallpaperData"]; | |
// Save the photo. | |
[controller performSelector:@selector(_savePhoto) withObject:nil]; | |
#pragma clang diagnostic pop | |
} | |
@end |
Hi MichaelMKenny
Thanks for your detailed reply.
I checked your code and that really works perfectly on ios 13 simulators.
I'm planning to create an app which where I can select/add pictures of a particular category and with in-app in the configuration screen, user can set either set both lock and home screen or any single option and user can set a timer in which app will change wallpaper on regular interval.
I was planning to add a payment option (IAP) to unlock some categories.
As per my knowledge with Jailbroken devices, I can't implement IAP. If I would like to move with this app with jailbreak devices only then can you please guide
- What payment options I need to add to unlock some categories?
- I can add logic to randomly chose images and call your methods in the background to set wallpaper
- Where do I need to publish the app for jailbroken devices?
Please advise and guide to get some insights to get this app done.
--
Regards
I'm sorry I don't think I can be of anymore assistance. My code is just a proof of concept. Hope you find a way to do what you want to do :)
Hi MichaelMKenny
Thanks for your detailed reply.
I checked your code and that really works perfectly on ios 13 simulators.
I'm planning to create an app which where I can select/add pictures of a particular category and with in-app in the configuration screen, user can set either set both lock and home screen or any single option and user can set a timer in which app will change wallpaper on regular interval.
I was planning to add a payment option (IAP) to unlock some categories.
As per my knowledge with Jailbroken devices, I can't implement IAP. If I would like to move with this app with jailbreak devices only then can you please guide
Please advise and guide to get some insights to get this app done.
--
Regards