Website Logo.

Bensge's Blog

Programming, iOS, Jailbreaking, the Web.

Auki APIs

Basic API

Auki has had a very basic API for 3rd party developers since 1.0. +[KJUARR doUrThing:<BBBulletin *>] can be used to activate auki with a BBBulletin (the message notification), or nil to present auki in compose mode. After serval developers requested additional, more extensive APIs, I decided to add a few useful APIs in version 1.3 which was released just this week on Cydia. The old API still works like it did in earlier versions, if you only need the basic API it’s totally fine to keep using it.

New APIs

Now to the actual new APIs:

1
+[KJUARR doUrThing:<BBBulletin *> withImages:<NSArray *>]

takes an array of UIImage objects which will get added to auki’s text input immediately.

1
+[KJUARR doUrThing:<BBBulletin *> withImages:<NSArray *> recipients:<NSArray *>]

also takes an array of images, but supports an additional array of recipient address strings (NSSString objects). These addresses can be phone numbers or emails, specifically. It is safe to pass nil or empty arrays as parameters for both arguments. Keep in mind that recipients are only supported in compose mode, hence the first argument, the BBBulletin notification must be nil.

Header file

For the ease of use, below is a header ready to be imported in your projects:

1
2
3
4
5
6
@interface KJUARR : NSObject
+(BOOL)doUrThing:(BBBulletin *)bulletin;
+(BOOL)doUrThing:(BBBulletin *)bulletin withImages:(NSArray *)images;
+(BOOL)doUrThing:(BBBulletin *)bulletin withRecipients:(NSArray *)recipients;
+(BOOL)doUrThing:(BBBulletin *)bulletin withImages:(NSArray *)images recipients:(NSArray *)recipients;
@end

Usage Examples

If your tweak allows the user to share a photo, why not allow sharing via auki? You can even append multiple images if you want.

1
2
UIImage *image = //Get your image
[objc_getClass("KJUARR") doUrThing:nil withImages:@[image]];

If your are developing some sort of a contact chooser UI, presenting auki ready to send that contact (or a group) a message is really easy as well.

1
2
3
NSString *firstContactEmail = @"[email protected]";
NSString *secondContactNumber = @"0123456789";
[objc_getClass("KJUARR") doUrThing:nil withImages:nil recipients:@[firstContactEmail,secondContactNumber]];

Conclusion

I hope everybody is happy with the new APIs and some developers can take advantage of them. If there is demand for additional APIs or bug reports, be sure to hit me up on Twitter or per email. Cya!

UIStatusBar Research

The iOS status bar is an interesting construct many jailbreak developers try to avoid messing with. After some research I thought I’d share some of my achievements to help other developers.

Items

Status bars contain so-called items, for example the WiFi item or the battery item, each item has a unique identifier. With some research I found out most items and their corresponding identifier:

Item identifier Name
0 time / clock
1 quite mode / DND
2 Airplane mode
3 signal strength
4 service item (carrier name)
5 data network
7 battery icon + lightning
8 battery percent
9 battery percent, looks same as 8 but isn’t. Maybe the not charging item?
10 bluetooth battery
11 bluetooth
12 TTY
13 alarm
16 location
17 rotation lock
19 AirPlay
20 assistant / Siri
21 VPN
22 call forwarding
23 activity / loading indicator
24 thermal color (?)

What to do with these item identifiers? What about enabling or disabling some items globally? Let’s enable the Siri status bar item:

1
2
[[SBStatusBarStateAggregator sharedInstance ] _setItem:20 enabled:YES]
//Returns a BOOL, YES if the status bar was changed and NO if it was already set

And ta-da, a siri icon in the status bar:


Data distribution

The status bar gets data from the status bar server UIStatusBarServer. The server and the status bar are not directly connected, a status bar state provider is a proxy between the two. A state provider conforms to the UIStatusBarStateProvider protocol, in SpringBoard SBStatusBarStateProvider and its subclasses (SBMainStatusBarStateProvider or SBNotificationCenterStatusBarStateProvider). State providers notify listening status bars about changes and edit the data, shwing or hiding specific items. SBMainStatusBarStateProvider enables and disables the time item dynamically (disabled on the lock screen, enabled otherwise), status bars get data from it by default. Hence to enable or disable the status bar time in (almost) all status bars, call the main state provider:

1
[[objc_getClass("SBMainStatusBarStateProvider") sharedInstance] enableTime:YES]

If you don’t want your status bar to hide the time dynamically, don’t use the main state provider (shown below)!

Styles

The status bar can also have different styles, infulencing the foreground and background color or the status bar height (incomplete list!).

Style Description
0x12F Notification center style
0x132 Big lockscreen style

When to use these styles is shown in the next paragraph.

Creating status bars

Creating a status bar isn’t very hard:

1
2
3
4
5
6
7
8
9
int statusBarStyle = 0x12F; //Normal notification center style
UIInterfaceOrientation orientation = UIApplication.sharedApplication.statusBar.statusBarWindow.orientation;
statusBar = [[UIStatusBar alloc] initWithFrame:CGRectMake(0,0,UIApplication.sharedApplication.statusBar.bounds.size.width,[UIStatusBar.class heightForStyle:statusBarStyle orientation:orientation]) showForegroundView:YES inProcessStateProvider:[[[objc_getClass("SBStatusBarStateProvider") alloc] init] autorelease]];
[statusBar requestStyle:statusBarStyle];
statusBar.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self addSubview:statusBar];

//After orientation changes
[statusBar setOrientation:UIApplication.sharedApplication.statusBarOrientation];

In this example we provide a custom state provider, the status bar won’t use the main provider and will always show the time item, even on the lock screen. To use the main provider, initialize the status bar with -initWithFrame: instead. Don’t forget to call -setOrientation: after initialization or if the interface orientation of your interface changed.

I hope this will help some other developers. If you have additions, please let me know about them. Happy coding!

Hello World

Welcome to my blog. You can expect tech-related posts here. You can wait for new, more exciting posts or come by and say hello on twitter