Dev:SBApplication
More actions
SBApplication is a class that represents individual applications. It contains anything you could possibly want to know about the application it represents.
Fetching SBApplications
SBApplicationController holds all known instances of SBApplication. There will usually just be a single instance per currently-running application. An instance can be retrieved using the wanted-application's bundle identifier.
//iOS 7-
SBApplication* app = [[SBApplicationController sharedInstance] applicationWithDisplayIdentifier:@"com.yourcompany.appname"];
// iOS 8+
SBApplication* app = [[SBApplicationController sharedInstance] applicationWithBundleIdentifier:@"com.yourcompany.appname"];
Fetching Frontmost App's SBApplication Instance
This method will return the frontmost application's SBApplication instance. If no app is currently running nil
will be returned. Internally it queries SBSceneManagerCoordinator to retrieve the application (if any) that is fulfilling the primary layout role.
[[SpringBoard sharedApplication] _accessibilityFrontMostApplication];
Fetching All Instances
SBApplicationController can provide an array containing all known instances of SBApplication.
[[SBApplicationController sharedInstanceIfExists] runningApplications];
Fetch "Now Playing" App
SBApplication *nowPlayingApp = [[SBMediaController sharedInstance] nowPlayingApplication];
Launching an SBApplication
SBUIController can be used to launch an SBApplication.
SBApplication *appToLaunch = [[SBApplicationController sharedInstanceIfExists] runningApplications][0];
[[SBUIController sharedInstanceIfExists] activateApplication:appToLaunch];
Classic Mode
Here are the constants that represent application classic mode depending on the screen type, retrieved from reversing SBApplicationClassicModeDescription(NSInteger)
or SBApplicationClassicModeForString(NSString *)
from SpringBoard.framework.
// The number suffix, if present, represents the diagonal size of the screen, in inches
typedef NS_ENUM(NSInteger, SBApplicationClassicMode) {
SBApplicationClassicModeNone = 0, // "none"
SBApplicationClassicModePhone = 1, // "phone"
SBApplicationClassicModePhone4 = 2, // "4" phone"
SBApplicationClassicModePhone4_7 = 3, // "4.7" phone"
SBApplicationClassicModePhone5_5 = 4, // "5.5" phone"
SBApplicationClassicModePhone5_8_Zoomed = 5, // "5.8" rounded phone (display zoom)"
SBApplicationClassicModePhone5_8 = 6, // "5.8" rounded phone"
SBApplicationClassicModePhone6 = 7, // "6" rounded phone"
SBApplicationClassicModePhone6_1 = 8, // "6.1" rounded phone"
SBApplicationClassicModePhone6_5 = 9, // "6.5" rounded phone"
SBApplicationClassicModePhone6_6 = 10, // "6.6" rounded phone"
SBApplicationClassicModePhone6_7 = 11, // "6.7" rounded phone"
SBApplicationClassicModePad = 12, // "pad"
SBApplicationClassicModePad10_5 = 13, // "10.5" pad"
SBApplicationClassicModePad12_9 = 14, // "12.9" pad"
SBApplicationClassicModePad12_9_Zoomed = 15, // "12.9" rounded pad (display zoom)"
SBApplicationClassicModePad10_9 = 16, // "10.9" rounded pad"
SBApplicationClassicModePad11 = 17, // "11" rounded pad"
SBApplicationClassicModePad11_1 = 18, // "11.1" rounded pad"
SBApplicationClassicModePad11_MoreSpace = 19, // "11" rounded pad (more space)"
SBApplicationClassicModePad12_9_Rounded = 20, // "12.9" rounded pad"
SBApplicationClassicModePad13 = 21, // "13" rounded pad"
SBApplicationClassicModePad12_9_MoreSpace = 22 // "12.9" rounded pad (more space)"
};
To disable launch animations simply apply the correct activation setting before calling -activateApplication:
.
[appToLaunch setFlag:1 forActivationSetting:1]; // flag 1 = ON, Activation Setting 1 = @"noAnimate"
Notes:
- This method will not respect parental control. However, you can determine if an SBApplication is restricted (parental locked) by using SBApplicationRestrictionController, which SBApplicationController holds an instance of.
SBApplication *appToCheck = [[SBApplicationController sharedInstanceIfExists] runningApplications][0];
BOOL appIsRestricted = [[[SBApplicationController sharedInstanceIfExists] restrictionController] isApplicationIdentifierRestricted:[appToCheck bundleIdentifier]];
Other Known Activation Flags
Flag | Setting | Description |
---|---|---|
0 | notASetting | Indicates this is not a valid setting |
1 | noAnimate | Launch without animations |
2 | animationDurationForOthersSuspension | |
3 | suspended | Launch the app in a suspended state |
4 | seo | |
5 | url | Specify a URL to open within the app |
6 | eventOnly | |
7 | animateWithoutPNG | Animate launch without using cached PNG snapshots |
8 | animatePreviousWithoutPNG | |
9 | preferSceneSnapshots | Prefer using scene snapshots for animation (vs launch images) |
10 | animateLiveContentASAP | Animate live content as soon as possible |
11 | animationDelay | Delay launch animation |
12 | reverseAnimation | Use reverse animation for launch |
13 | sourceIdentifier | |
14 | annotation | |
15 | launchOptions | Specify additional launch options |
16 | launchImageName | Specify a custom launch image |
17 | userLaunchEventTime | |
18 | continuousUserLaunchEventTime | |
19 | classicOverride | |
20 | appLink | |
21 | appLinkState | |
22 | escapingAppLink | |
23 | breadcrumbSourceIdentifier | |
24 | breadcrumbNavigationAction | |
25 | spotlightVisible | |
26 | todayViewVisible | |
27 | bannerLongLookVisible | |
28 | processLaunchIntent | |
30 | fromHomeScreen | Indicate that the app was launched from the home screen |
31 | fromLocked | Indicate that the app was launched from the locked state |
32 | fromContinuity | Launched via Continuity feature |
33 | fromBanner | Launched from a notification banner |
34 | fromBulletinList | Launched from a bulletin list |
35 | fromAssistant | Launched by Siri |
36 | fromCC | Launched from Control Center |
37 | fromIconWithLeafIdentifier | Launched from an icon with a specific identifier |
38 | fromSpotlight | Launched from Spotlight search |
39 | fromBreadcrumb | Launched from a breadcrumb navigation |
40 | fromCommandTab | Launched using Command+Tab shortcut |
41 | fromSystemServiceRequest | Launched by a system service request |
42 | fromTrustedSystemServiceRequest | Launched by a trusted system service request |
43 | fromShortcutItem | Launch the app from a shortcut item |
44 | fromWidget | Indicate that the app was launched from a widget |
45 | fromNotificationContentExtension | Launched from a notification content extension |
46 | launchForegroundUnderLockScreen | Launch the app in the foreground even when the device is locked |
47 | ignoringOcclusionsReason | |
48 | siriContinuityAppSuggestion | Launched from a Siri Continuity app suggestion |
49 | dontResetSwitchAppList | Prevent resetting the app switcher list |
50 | animateOthersSuspension | Animate the suspension of other apps during launch |
51 | fromDeactivatingAlert | Launched from a deactivating alert |
52 | animationDuration | Set the duration for the launch animation |
Useful Methods
These are a few of the useful items in SBApplication.
//the apps bundle id
- (NSString *)bundleIdentifier;
//is it SpringBoard's instance
- (BOOL)isSpringBoard;
//app location info
- (NSString *)path;
- (NSString *)dataContainerPath;
- (NSString *)bundleContainerPath;
- (NSString *)bundleVersion;
- (NSString *)sandboxPath;
//general info
- (BOOL)isSetup;
- (BOOL)isMobilePhone;
- (BOOL)isFaceTime;
- (BOOL)behavesLikePhone;
- (BOOL)isWebApplication;
- (BOOL)isWatchApplication;
- (BOOL)isNowPlayingApplication;
- (BOOL)isNowRecordingApplication;
- (BOOL)showsProgress;
- (BOOL)isRecordingAudio;
- (BOOL)isRunning;
- (BOOL)hasStartedLaunching;
//the string displayed under the icon
- (NSString *)displayName;
//has it been launched at some point in SpringBoard's life
- (BOOL)hasBeenFrontmost;
//badge number
- (id)badgeNumberOrString;
//returns the app's FBScene instance, useful for doing context host view stuff
- (FBScene *)mainScene;
Application Info.plist
SpringBoard will recognize the following Info.plist keys:
- UISystemProvisioning
- SBDemoRole[1]
- SBIsRevealable[1][2]
- SBUsesNetwork[3]
- UIJetsamPriority
- SBIconClass
- SBSpotlightIcons
- UIRoles
- SBMachServices
- disabled
- CFBundleIconFile
- SPSearchDomainLaunchInfo
- SBAppTags[4][5]
- Other UIKit keys described in http://developer.apple.com/IPhone/library/documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html
Starting from 3.2 these documented keys are also recognized:
- ProductType, UIDeviceFamily, DeviceFamily[6]
- UIAppFonts
- UIFileSharingEnabled
- UISupportedInterfaceOrientations
As of iOS 8, the following undocumented key is also recognized:
- _UILaunchAlwaysFullScreen[7]
References
- ^ a b http://blogs.oreilly.com/iphone/2008/11/hunting-down-infoplist-prefere.html [Archived 2010-01-04 at the Wayback Machine]
- ^ https://web.archive.org/web/20091214205651/http://www.tuaw.com/2007/11/29/enable-app-hiding-on-your-iphone/
- ^ http://stackoverflow.com/questions/596589/iphone-sdk-internet-connection-detection
- ^ http://www.ifans.com/forums/threads/what-keeps-these-hidden.331215/#post-2552445 [Archived 2016-06-06 at the Wayback Machine]
- ^ http://www.ifans.com/forums/threads/hide-applications.76176/#post-717439 [Archived 2013-09-18 at the Wayback Machine]
- ^ The keys ProductType and DeviceFamily are private but equivalent to UIDeviceFamily.
- ^ http://pastebin.com/XmRqevnD