{"id":20340558,"url":"https://github.com/strongself/ramblerappdelegateproxy","last_synced_at":"2025-04-11T23:24:36.175Z","repository":{"id":62452519,"uuid":"55062199","full_name":"strongself/RamblerAppDelegateProxy","owner":"strongself","description":"divide et impera","archived":false,"fork":false,"pushed_at":"2017-02-21T20:25:00.000Z","size":37,"stargazers_count":82,"open_issues_count":1,"forks_count":12,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-04-10T11:59:54.084Z","etag":null,"topics":["appdelegate","architecture","nsproxy","srp"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/strongself.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-30T12:45:22.000Z","updated_at":"2024-12-02T19:11:34.000Z","dependencies_parsed_at":"2022-11-01T23:45:46.253Z","dependency_job_id":null,"html_url":"https://github.com/strongself/RamblerAppDelegateProxy","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strongself%2FRamblerAppDelegateProxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strongself%2FRamblerAppDelegateProxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strongself%2FRamblerAppDelegateProxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strongself%2FRamblerAppDelegateProxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/strongself","download_url":"https://codeload.github.com/strongself/RamblerAppDelegateProxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248493762,"owners_count":21113315,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["appdelegate","architecture","nsproxy","srp"],"created_at":"2024-11-14T21:22:34.011Z","updated_at":"2025-04-11T23:24:36.146Z","avatar_url":"https://github.com/strongself.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Overview\n\n**RamblerAppDelegateProxy** is your best cure against massive `AppDelegate` class. It provides a nice and clean way to divide all of the `AppDelegate` responsibilities between multiple helper classes.\n\n![Picture](http://www.androidphone.su/wp-content/uploads/2015/09/aaazaaa.png)\n\nJust imagine, that instead of 2k lines of code monster you have multiple simple classes:\n\n- `StartAppDelegate` - configures application on start up,\n- `AnalyticsAppDelegate` - configures analytics services,\n- `RemoteNotificationAppDelegate` - handles push-notifications,\n- `SpotlightAppDelegate` - handles start from spotlight results,\n- `HandoffAppDelegate` - handles start from handoff,\n- `DeepLinkAppDelegate` - incapsulates deep linking logic,\n- and anything else.\n\n### Key features\n\n- Provides all the infrastructure - you should only create your own mini-`AppDelegate` classes with single responsibilities.\n- Has simple dependency injection system for injecting your mini-instances,\n- Battle-tested into a lot of *Rambler\u0026Co* projects.\n\n### Installation\n\n`pod RamblerAppDelegateProxy`\n\n### Usage\nCreate a `RemoteNotificationAppDelegate` class which conforms to `UIApplicationDelegate` protocol.\n\n```objc\n@interface RemoteNotificationAppDelegate : NSObject \u003cUIApplicationDelegate\u003e\n\n@end\n...\n@implementation RemoteNotificationAppDelegate\n\n- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {\n    NSDictionary *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];\n    if (notification) {\n        NSLog(@\"Launching from push %@\", notification);\n    }\n    return YES;\n}\n\n- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {\n    NSLog(@\"Did register for remote notifications\");\n}\n\n- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {\n   NSLog(@\"Did receive remote notification\");}\n}\n\n@end\n```\n\nChange the `main.m` file implementation:\n\n```objc\nint main(int argc, char * argv[]) {\n    @autoreleasepool {\n        [[RamblerAppDelegateProxy injector] addAppDelegates:@[[RemoteNotificationAppDelegate new]]];\n\n        return UIApplicationMain(argc, argv, nil, NSStringFromClass([RamblerAppDelegateProxy class]));\n    }\n}\n```\n\nUse your `RemoteNotificationAppDelegate` in the same way as the standart `AppDelegate` class - just remember to not mess its responsibilities.\n\n### Troubleshooting\n\nBased on the concept, the proxy forwards only the methods defined in the protocol UIApplicationDelegate. If you need a additional method that must be implemented in AppDelegate, you need to create a subclass and implement this method in this class.\n```objc\n@interface AppDelegate : UIResponder \u003cUIApplicationDelegate\u003e\n\n@property (strong, nonatomic) UIWindow *window;\n\n@end\n```\nThis subclass should be set as a default.\n```objc\n[[RamblerAppDelegateProxy injector] setDefaultAppDelegate:[AppDelegate new]];\n```\nThis is necessary for example if you are using Typhoon. For injection depending in AppDelegates need to write a definition for RamblerAppDelegateProxy.\n```objc\n@implementation ApplicationAssembly\n\n- (RamblerAppDelegateProxy *)applicationDelegateProxy {\n    return [TyphoonDefinition withClass:[RamblerAppDelegateProxy class]\n                          configuration:^(TyphoonDefinition *definition) {\n                                [definition injectMethod:@selector(addAppDelegates:)\n                                              parameters:^(TyphoonMethod *method) {\n                                                    NSArray *appDelegates = @[\n                                                        [self remoteNotificationAppDelegate]\n                                                    ];\n                                                    [method injectParameterWith:appDelegates];\n                                                }];\n                          }];\n}\n\n- (id\u003cUIApplicationDelegate\u003e)remoteNotificationAppDelegate {\n    return [TyphoonDefinition withClass:[RCMLaunchingAppDelegate class]\n                          configuration:^(TyphoonDefinition *definition) {\n                          }];\n}\n\n@end\n```\n\n### Authors\n\n[Vadim Smal](https://github.com/CognitiveDisson)\n\n### License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrongself%2Framblerappdelegateproxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstrongself%2Framblerappdelegateproxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrongself%2Framblerappdelegateproxy/lists"}