All Projects → strongself → RamblerAppDelegateProxy

strongself / RamblerAppDelegateProxy

Licence: MIT license
divide et impera

Programming Languages

shell
77523 projects
objective c
16641 projects - #2 most used programming language
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to RamblerAppDelegateProxy

Attrs
Python Classes Without Boilerplate
Stars: ✭ 3,786 (+4461.45%)
Mutual labels:  srp
mbedtls-esp8266
Updated and Upgraded mbedTLS library for the ESP8266 (probably ESP32 too)
Stars: ✭ 13 (-84.34%)
Mutual labels:  srp
scst
No description or website provided.
Stars: ✭ 61 (-26.51%)
Mutual labels:  srp
AppWindowUtility
This utility is for Unity to configure application window style. With this utility, you can make your application window transparent, frameless and more.
Stars: ✭ 26 (-68.67%)
Mutual labels:  srp
Volumetric-Occlusion-Mask-SRP
Using SRP to create a volumetric occlusion mask for objects to use in their render pass
Stars: ✭ 17 (-79.52%)
Mutual labels:  srp
aws-sdk-net-extensions-cognito
An extension library to assist in the Amazon Cognito User Pools authentication process
Stars: ✭ 80 (-3.61%)
Mutual labels:  srp
srptools
Tools to implement Secure Remote Password (SRP) authentication
Stars: ✭ 22 (-73.49%)
Mutual labels:  srp
SRP
Secure Remote Password (SRP) for Swift
Stars: ✭ 44 (-46.99%)
Mutual labels:  srp
pundit kit
Extension for pundit which allows to describe namespaces of policies in routes-like style
Stars: ✭ 12 (-85.54%)
Mutual labels:  srp
URP-Sun-Shafts
A URP port of Unity's classic Standard Assets Effects package's Sun Shaft effect
Stars: ✭ 36 (-56.63%)
Mutual labels:  srp
cognito-srp
Go library for AWS Cognito SRP
Stars: ✭ 40 (-51.81%)
Mutual labels:  srp
GoogleDriveBrowser
Goole Drive Download Library for iOS
Stars: ✭ 13 (-84.34%)
Mutual labels:  appdelegate
HttpProxyExample
HttpProxyExample-Example of using NSProxy
Stars: ✭ 47 (-43.37%)
Mutual labels:  nsproxy

Overview

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.

Picture

Just imagine, that instead of 2k lines of code monster you have multiple simple classes:

  • StartAppDelegate - configures application on start up,
  • AnalyticsAppDelegate - configures analytics services,
  • RemoteNotificationAppDelegate - handles push-notifications,
  • SpotlightAppDelegate - handles start from spotlight results,
  • HandoffAppDelegate - handles start from handoff,
  • DeepLinkAppDelegate - incapsulates deep linking logic,
  • and anything else.

Key features

  • Provides all the infrastructure - you should only create your own mini-AppDelegate classes with single responsibilities.
  • Has simple dependency injection system for injecting your mini-instances,
  • Battle-tested into a lot of Rambler&Co projects.

Installation

pod RamblerAppDelegateProxy

Usage

Create a RemoteNotificationAppDelegate class which conforms to UIApplicationDelegate protocol.

@interface RemoteNotificationAppDelegate : NSObject <UIApplicationDelegate>

@end
...
@implementation RemoteNotificationAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    NSDictionary *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
    if (notification) {
        NSLog(@"Launching from push %@", notification);
    }
    return YES;
}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    NSLog(@"Did register for remote notifications");
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
   NSLog(@"Did receive remote notification");}
}

@end

Change the main.m file implementation:

int main(int argc, char * argv[]) {
    @autoreleasepool {
        [[RamblerAppDelegateProxy injector] addAppDelegates:@[[RemoteNotificationAppDelegate new]]];

        return UIApplicationMain(argc, argv, nil, NSStringFromClass([RamblerAppDelegateProxy class]));
    }
}

Use your RemoteNotificationAppDelegate in the same way as the standart AppDelegate class - just remember to not mess its responsibilities.

Troubleshooting

Based 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.

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end

This subclass should be set as a default.

[[RamblerAppDelegateProxy injector] setDefaultAppDelegate:[AppDelegate new]];

This is necessary for example if you are using Typhoon. For injection depending in AppDelegates need to write a definition for RamblerAppDelegateProxy.

@implementation ApplicationAssembly

- (RamblerAppDelegateProxy *)applicationDelegateProxy {
    return [TyphoonDefinition withClass:[RamblerAppDelegateProxy class]
                          configuration:^(TyphoonDefinition *definition) {
                                [definition injectMethod:@selector(addAppDelegates:)
                                              parameters:^(TyphoonMethod *method) {
                                                    NSArray *appDelegates = @[
                                                        [self remoteNotificationAppDelegate]
                                                    ];
                                                    [method injectParameterWith:appDelegates];
                                                }];
                          }];
}

- (id<UIApplicationDelegate>)remoteNotificationAppDelegate {
    return [TyphoonDefinition withClass:[RCMLaunchingAppDelegate class]
                          configuration:^(TyphoonDefinition *definition) {
                          }];
}

@end

Authors

Vadim Smal

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].