Difference between revisions of "BulletinBoard.framework"

From iPhone Development Wiki
Jump to: navigation, search
(Created page with "BulletinBoard.framework is a private framework available since iOS 5 which handles Local and Push notifications.")
 
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
BulletinBoard.framework is a private framework available since iOS 5 which handles Local and Push notifications.
+
{{infobox Framework
 +
| vis = Private
 +
| since = 5.0
 +
| classID = BB
 +
| bundle = com.apple.bulletinboard
 +
}}
 +
'''BulletinBoard''' is a private framework which handles Local and Push notifications.
 +
 
 +
= BulletinBoard Findings: =
 +
By ''Amro Thabet'' aka ''Brave Heart''
 +
 
 +
== The default action of a BBBulletin, use: ==
 +
<source lang=objc>
 +
@interface BBBulletin : NSObject
 +
@property (nonatomic, copy) BBAction *defaultAction;
 +
@end
 +
 
 +
BBBulletin *bulletin;
 +
bulletin.defaultAction;
 +
</source>
 +
 
 +
== Sub-actions (those that are displayed when the notification is swiped down), use: ==
 +
<source lang=objc>
 +
BBBulletin *bulletin;
 +
[bulletin supplementaryActions];
 +
</source>
 +
 
 +
== To observe new notifications as they arrive: ==
 +
<source lang=objc>
 +
%hook BBServer
 +
-(void)publishBulletin:(BBBulletin *)bulletin destinations:(unsigned int)arg2 alwaysToLockScreen:(BOOL)arg3
 +
{
 +
/* code */
 +
}
 +
%end
 +
</source>
 +
 
 +
== To get a response to a BBAction: ==
 +
<source lang=objc>
 +
BBBulletin *bulletin;
 +
BBResponse *bbresponse = [bulletin responseForAction:action];
 +
</source>
 +
 
 +
== To set a reply text in the response to the BBAction: ==
 +
(Edit REPLY_TEXT to your liking)
 +
<source lang=objc>
 +
NSMutableDictionary *context = [bbresponse.context mutableCopy];
 +
if(context == nil)
 +
context = [[NSMutableDictionary alloc] init];
 +
 
 +
context[@"userResponseInfo"] = @{@"UIUserNotificationActionResponseTypedTextKey": REPLY_TEXT };
 +
bbresponse.context = context;
 +
</source>
 +
 
 +
== To handle a BBResponse (respond to a BBAction): ==
 +
<source lang=objc>
 +
BBServer *bulletinServer;
 +
NSMutableSet *observers = [bulletinServer valueForKey:@"_observers"];
 +
BBObserverClientProxy *observer = [observers anyObject];
 +
[observer handleResponse:bbresponse];
 +
</source>
 +
 
 +
== To remove a notification (has to be done after handling a BBResponse): ==
 +
If __BBServerQueue isn't used, an error would be fired (as of iOS 9).
 +
This is placed at the beginning of the header/source file
 +
<source lang=objc>
 +
extern dispatch_queue_t __BBServerQueue;
 +
</source>
 +
 
 +
This is placed where removing the notification is required
 +
<source lang=objc>
 +
dispatch_sync(__BBServerQueue, ^{
 +
BBServer *bulletinServer;
 +
[bulletinServer _clearBulletinIDs:@[bulletin.bulletinID] forSectionID:bulletin.sectionID shouldSync:YES];
 +
});
 +
</source>
 +
 
 +
== To find out if a BBAction is for a reply-able action (like the SMS reply action): ==
 +
<source lang=objc>
 +
BBAction *action;
 +
if(action.behavior == UIUserNotificationActionBehaviorTextInput)
 +
{
 +
/* code */
 +
}
 +
</source>
 +
 
 +
== To find a BBAction’s title: ==
 +
<source lang=objc>
 +
BBAction *action;
 +
NSString *title = action.appearance.title;
 +
</source>
 +
 
 +
== To find the contents of a notification BBBulletin: ==
 +
<source lang=objc>
 +
BBContent *content = bulletin.content;
 +
</source>
 +
 
 +
{{Navbox Classes}}
 +
{{Navbox Frameworks}}

Latest revision as of 16:30, 8 July 2016

BulletinBoard.framework
Private Framework
com.apple.bulletinboard
Availabile 5.0 – present
Class Prefix BB

BulletinBoard is a private framework which handles Local and Push notifications.

BulletinBoard Findings:

By Amro Thabet aka Brave Heart

The default action of a BBBulletin, use:

@interface BBBulletin : NSObject
@property (nonatomic, copy) BBAction *defaultAction;
@end

BBBulletin *bulletin;
bulletin.defaultAction;

Sub-actions (those that are displayed when the notification is swiped down), use:

BBBulletin *bulletin;
[bulletin supplementaryActions];

To observe new notifications as they arrive:

%hook BBServer
-(void)publishBulletin:(BBBulletin *)bulletin destinations:(unsigned int)arg2 alwaysToLockScreen:(BOOL)arg3
{
	/* code */
}
%end

To get a response to a BBAction:

BBBulletin *bulletin;
BBResponse *bbresponse = [bulletin responseForAction:action];

To set a reply text in the response to the BBAction:

(Edit REPLY_TEXT to your liking)

NSMutableDictionary *context = [bbresponse.context mutableCopy];
if(context == nil)
	context = [[NSMutableDictionary alloc] init];

context[@"userResponseInfo"] = @{@"UIUserNotificationActionResponseTypedTextKey": REPLY_TEXT };
bbresponse.context = context;

To handle a BBResponse (respond to a BBAction):

BBServer *bulletinServer;
NSMutableSet *observers = [bulletinServer valueForKey:@"_observers"];
BBObserverClientProxy *observer = [observers anyObject];
[observer handleResponse:bbresponse];

To remove a notification (has to be done after handling a BBResponse):

If __BBServerQueue isn't used, an error would be fired (as of iOS 9). This is placed at the beginning of the header/source file

extern dispatch_queue_t __BBServerQueue;

This is placed where removing the notification is required

dispatch_sync(__BBServerQueue, ^{
	BBServer *bulletinServer;
	[bulletinServer _clearBulletinIDs:@[bulletin.bulletinID] forSectionID:bulletin.sectionID shouldSync:YES];
});

To find out if a BBAction is for a reply-able action (like the SMS reply action):

BBAction *action;
if(action.behavior == UIUserNotificationActionBehaviorTextInput)
{
	/* code */
}

To find a BBAction’s title:

BBAction *action;
NSString *title = action.appearance.title;

To find the contents of a notification BBBulletin:

BBContent *content = bulletin.content;