I want to change iPhone's Messages notification preference, programmatically in a jailbreak app. Any private API can be used and the app is not for the AppStore, so kindly don't say that "app will not be approved by Apple".
How can I turn off the notification for incoming messages?
Add to your app entitlements com.apple.bulletinboard.settings
key with bool value equal to YES
.
Link to private BulletinBoard.framework. It contains all required classes.
We are going to work with an instance of BBSettingsGateway
BBSettingsGateway* settings = [[BBSettingsGateway alloc] init];
Getting all notification preferences
[settings getSectionInfoWithCompletion:^(NSArray* sections){
}];
sections
will contain array of BBSectionInfo
objects. Theirs sectionID
property contains bundle id of target app. Search for com.apple.MobileSMS
to find messages app preferences.
BBSectionInfo
contains all notifications preferences. For example, you can disable all notifications like this
messagesAppSectionInfo.showsInNotificationCenter = NO;
Applying changes
[settings setSectionInfo:messagesAppSectionInfo forSectionID:@"com.apple.MobileSMS"];
And complete example to disable all notifications for messages app:
BBSettingsGateway* settings = [[BBSettingsGateway alloc] init];
[settings getSectionInfoWithCompletion:^(NSArray* sections){
for (BBSectionInfo* info in sections)
{
if ([info.sectionID isEqualToString:@"com.apple.MobileSMS"])
{
info.showsInNotificationCenter = NO;
[settings setSectionInfo:info forSectionID:@"com.apple.MobileSMS"];
break;
}
}
}];