Saturday 2 November 2013

Presenting a MFMailComposeViewController in a Preference Bundle

So, you want to throw up a modal mail form in your Preference Bundle for your tweak, perhaps in a support section? Sweet! Thankfully it's exceedingly simple; there's only one change to consider when comparing to Apple's example code for presenting a MFMailComposeViewController.


-(void)composeSupportEmail:(id)sender {
    NSString *emailTitle = @"Title";
    NSString *messageBody = @"Message";
    NSArray *toRecipents = [NSArray arrayWithObject:@"foo@bar.com"];
    
    MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
    mc.mailComposeDelegate = self;
    [mc setSubject:emailTitle];
    [mc setMessageBody:messageBody isHTML:NO];
    [mc setToRecipients:toRecipents];
    
    // Present mail view controller on screen
    [self.parentController presentModalViewController:mc animated:YES];
}

-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
    [self.parentController dismissModalViewControllerAnimated:YES];
}

In the code above, all that has been changed is to use the parentController property inherited from PSViewController as the view to call presentModalViewController:animated: from. And that's all there is to it!

Monday 5 August 2013

Getting the homescreen and lockscreen wallpaper programatically (iOS)

Here's a small method that will return the homescreen or lock screen wallpaper of an iOS device as an UIImage.

#import <SpringBoard/SBWallpaperView>
#import <objc/runtime.h>

-(UIImage*)wallpaper:(int)var {

        SBWallpaperView *view = [[objc_getClass("SBWallpaperView") alloc] initWithOrientation:UIImageOrientationUp variant:var];
        UIImage *img = [[view.image copy] autorelease];
        [view release];
        return img;

}

Pass 0 for the lockscreen wallpaper, and 1 for the homescreen; feel free to change the orientation as necessary. Enjoy!

Monday 6 May 2013

So, where have I been?

As you can probably see, it's been a very long time since I last posted here! A lot of things have happened recently, but with schoolwork and everything, there hasn't been much time to do much else.

I've begun to learn Objective-C recently, and have an iPhone tweak that's about to go into a beta stage soon, once all the major bugs are finally ironed out. It's been tough to learn as I'm teaching myself it, but its very fun, and extremely rewarding. Also, I've been helping out over in the ModMyi community, creating a preference pane for a fantastic theme by the name of Strife (seriously, check it out, it's brilliant!).

If you want to check out any of my code, my github is https://github.com/Matchstic

The iPhone/Lumia project I was working on last year has seemed to died out currently, plus I've now got an ever-so-fancy transparent back on the iPhone - always turns heads when I'm out, people really think it's awesome to see the internals of an iPhone! I'll probably start work on it again at some point, although there was some fitting issues after I got the phone, so not sure if it'll work a-ok or not in the end.

Not sure if I've already mentioned this, but I now have a business - iRepairIT! It's only a small side thing, but I make a nice bit of money from it when I have time to fix things. The as yet unfinished website for it is http://i-repairit.webuda.com, but all my contact details are there if you need anything fixing.

"Here's to the crazy ones…"
-- Steve Jobs

Sunday 17 February 2013

A bit of a rant...


<rant>

Recently, I've become a bit disillusioned with Apple, mostly to do with their policy towards older devices and new features in both iOS and Mac OS X, and also with jailbreaking.

First off, I have an iPhone 4, with Siri and FaceTime over 3G, both of which are features only available on newer generations. Both of these run flawlessly, which really undermines Apple's argument that older devices can't support these newer features. I know of someone with an iPhone 3GS with Siri, so I honestly can't see why Apple would force iOS revisions with reduced features onto devices that can easily support them. Granted, on the 3GS, Siri doesn't run perfectly, but there's no reason to restrict it from the iPad 2 either - it has the same processor as the 4S! Same processor = same power, so it should be able to run it! In fact, I have first-hand experience of it running flawlessly, so the only reason I can see why Apple does this is for marketing, and money, not for the user experience. In the past, I'm certain Apple would have given users all features available in OS revisions to improve user experience, so why should Apple do this now? I do see the argument for Apple doing this - as a company, it would give them more profit - but in terms of user experience, it's a poor choice to make.

Now, I'm not an Apple hater - I personally own a few Apple devices, and use them all daily, even developing apps on them - but it's things like this that this that get under my skin. Users should not have to muck about in the system partiton of their devices to gain these features (although, I personally enjoy doing this). Which brings us to the subject of jailbreaking.

With jailbreaking, a whole new world is introduced to an iDevice - complete freedom over the device you bought. In fact, it can easily be argued that jailbreaking forced Apple's hand to bring about the App Store; the jailbreak community created Installer - a third-party "App Store" with apps for iPhone OS 1.0 - which showed just how innovative this community is. Since then, Apple has actually copied some features from the jailbreak community - the new Notification system introduced in iOS 5? That was a jailbreak tweak; same thing with FaceTime over 3G. Without this innovation, I'm certain iOS wouldn't have changed much from 2.0 to now. So, why does Apple try to dissuade people from enriching themselves and iDevice? According to their wiki, jailbreaking causes severe instabilities (couldn't find the link, sorry!). In truth, it's the complete opposite. Remember iOS 4.3.4 and .5? The security vulnerability they patched was patched by the jailbreak community weeks before they were released. If this doesn't show just how beneficial jailbreaking can be, then I don't know what will.

More importantly though, Apple attempting to prevent people from jailbreaking, such as through new security in the iOS kernel like KASLR, seems to suggest they want to prevent people from innovating. To me, this seems ridiculous. Instead, they should begin to open up iOS, and allow people to customise iOS to how they want it, rather than how Apple dictates. I have a feeling that doing this may even persuade a sizeable amount of Android users to switch over to iOS, since they currently enjoy much more customisability than stock iOS does.

Sorry if this seems rather biased - I am a member of the jailbreak community, and working on my first MS tweak - and if it made no sense whatsoever, but what I'm trying to say is that I believe that Apple shouldn't hold back software features to people on older hardware to force them to upgrade hardware, and that they should open up iOS much more than it currently is. Opening up iOS could be the best thing Apple could do in this situation; they would gain the combined resources of a community that has years of experience in pushing iOS to it's limits. Hopefully, an employee at Apple HQ on 1 Infinite Drive may see this, so I ask you, what's not to lose?
</rant>