All Projects → allegro → slinger

allegro / slinger

Licence: other
Slinger - deep linking library for Android

Programming Languages

java
68154 projects - #9 most used programming language
IDL
102 projects

Projects that are alternatives of or similar to slinger

FranklinPay-iOS
Secure Dollar Wallet
Stars: ✭ 35 (+34.62%)
Mutual labels:  deep-links
Shortbread
Android library that creates app shortcuts from annotations
Stars: ✭ 1,803 (+6834.62%)
Mutual labels:  deep-links
Jlroutes
URL routing library for iOS with a simple block-based API
Stars: ✭ 5,528 (+21161.54%)
Mutual labels:  deep-links
Deeplinkdispatch
A simple, annotation-based library for making deep link handling better on Android
Stars: ✭ 4,108 (+15700%)
Mutual labels:  deep-links
node-deeplink
Easily create an endpoint in your web server that redirects deep links to mobile apps
Stars: ✭ 85 (+226.92%)
Mutual labels:  deep-links
deeplink.js
Redirect mobile website users to your native iOS and Android (browser only)
Stars: ✭ 15 (-42.31%)
Mutual labels:  deep-links
capacitor-branch-deep-links
Capacitor plugin for branch.io deep links
Stars: ✭ 22 (-15.38%)
Mutual labels:  deep-links
swift-sdk
Iterable's iOS SDK. Receive and track pushes to Iterable from your iOS app.
Stars: ✭ 65 (+150%)
Mutual labels:  deep-links
iterable-android-sdk
Iterable's Android SDK. Receive and track pushes to Iterable from your Android app.
Stars: ✭ 19 (-26.92%)
Mutual labels:  deep-links

Slinger - deep linking library for Android

Build Status

Slinger is a small Android library for handling custom Uri which uses regular expression to catch and route URLs which won’t be handled by normal intent-filter mechanism.

With slinger it’s possible to provide deep links for quite complicated URLs.

Scheme of Slinger resolving Activities using regular expression

How do I use it?

Declare Activity in your manifest with your own IntentResolver that will handle links within particular domain.

<activity
  android:name="pl.allegro.android.slinger.SlingerActivity"
  android:excludeFromRecents="true"
  android:noHistory="true"
  android:theme="@style/android:Theme.NoDisplay">
  <meta-data
    android:name="IntentResolver"
    android:value="com.my.appp.ExampleIntentResolver"/>
    <intent-filter android:label="@string/app_name">
      <action android:name="android.intent.action.VIEW"/>
      <category android:name="android.intent.category.DEFAULT"/>
      <category android:name="android.intent.category.BROWSABLE"/>
      <data
        android:host="example.com"
        android:pathPattern="/.*"
        android:scheme="http"/>
    </intent-filter>
</activity>

IntentResolver is a class that redirects URLs to concrete Activities based on regular expressions.

@Keep
public class ExampleIntentResolver extends IntentResolver {

  private List<RedirectRule> rules;

  public ExampleIntentResolver(Activity activity) {
    super(activity);
    rules = asList(getRedirectRuleForAboutActivity(activity));
  }

  private RedirectRule getRedirectRuleForAboutActivity(Activity activity) {
    return RedirectRule.builder()
                       .intent(new Intent(activity, MyConcreteActivityA.class))
                       .pattern("http://example.com/abc\\\\.html\\\\?query=a.*")
                       .build();
  }

  @NonNull @Override public Iterable<RedirectRule> getRules() {
    return rules;
  }
}

In case when no redirect rule is matched IntentResolver will fallback to default Intent - Uri with ACTION_VIEW.

Customizing

Matching Activities

In order to provide other mechanism than regular expression matching you can override resolveIntentToSling in IntentResolver

Enriching Slinged Intents with Referrer and input URL

Slinger enriches Intents with URL and referrer by default. This can be changed by overriding enrichIntent in IntentResolver

@Keep
public class ExampleIntentResolver extends IntentResolver {

  @NonNull
  @Override
  public Intent resolveIntentToSling(@NonNull Uri originatingUri) {
    // implement own intent resolving strategy here
    return super.resolveIntentToSling(originatingUri);
  }
  
  @Override
  public Intent enrichIntent(Activity parentActivity, Intent resolvedIntent, Uri originatingUri) {
    // enrich resolved intent with custom data
    return super.enrichIntent(parentActivity, resolvedIntent, originatingUri).putExtra("foo","bar");
  }
}

Security considerations

Slinger does not sanitize input in any way. So providing security for application is your responsibility.

License

slinger is published under Apache License 2.0.

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