Skip to content
This repository has been archived by the owner on Oct 1, 2018. It is now read-only.

Working with the main branch.io plugin #33

Closed
edparsons opened this issue Jan 14, 2016 · 5 comments
Closed

Working with the main branch.io plugin #33

edparsons opened this issue Jan 14, 2016 · 5 comments
Labels

Comments

@edparsons
Copy link

Will this plugin work nicely with the main branch.io cordova plugin, or will I need to do some work to get them to work together or does one include the features of the other?

https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK

@nikDemyankov
Copy link
Member

Never tried them together, so can't tell. You are free to experiment :) But I think it is totally possible.

UL plugin just prepares your application to work with universal links by executing some hooks on the build phase. Plus, it has some native code to process the links, that you open. Hooks should not conflict, since according to branch.io plugin documentation developer should do this by hand. The only problem can be with the native code. But I think this is solvable.

@edparsons
Copy link
Author

ok, I'll experiment and if I need to adjust either plugin's native code, I'll pull request it back :)

@boxfish
Copy link

boxfish commented Feb 13, 2016

I tried to add both plugins into the project, and then branch.io plugin failed to get the deep link data in callbacks. It turned out that the both plugins tries to override the AppDelegate's application:continueUserActivity method and caused the conflict. I'm not sure how to solve this issue.

@nikDemyankov
Copy link
Member

As a workaround you can mix implementation from both plugins.

  1. Install both plugins.

  2. In the AppDelegate+BNCDevice.m include header for UL plugin on line 4:

    #import "CULPlugin.h"
    
  3. In the AppDelegate+BNCDevice.m modify swizzleApplication:(UIApplication *)application method like so:

    - (BOOL)swizzleApplication:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler {
      if (![userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
          if (swizzled) {
              return [self swizzleApplication:application continueUserActivity:userActivity restorationHandler:restorationHandler];
          }
    
          return NO;
      }
    
      // get instance of the UL plugin
      CULPlugin *ulPlugin = [self.viewController getCommandInstance:PLUGIN_NAME];
      if (ulPlugin == nil) {
          return NO;
      }
    
      BNCDevice *device = [self.viewController getCommandInstance:@"BranchDevice"];
    
      return [device handleUserActivity:userActivity] && [ulPlugin handleUserActivity:userActivity];
    }
    
  4. Delete AppDelegate+CULPlugin.h and AppDelegate+CULPlugin.m files from the project.

As a result, branch's AppDelegate will call both UL plugin and his own implementation.

@nordnet-deprecation-bot
Copy link
Contributor

👋 Hi! Thank you for your interest in this repo.

😢 We are not using nordnet/cordova-universal-links-plugin anymore, and we lack the manpower and the experience needed to maintain it. We are aware of the inconveniece that this may cause you. Feel free to use it as is, or create your own fork.

🔒 This will now be closed & locked.

ℹ️ Please see #160 for more information.

@nordnet nordnet locked and limited conversation to collaborators Sep 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants