Skip to content

Instantly share code, notes, and snippets.

@savyounts
Created April 29, 2019 18:36
Show Gist options
  • Save savyounts/aebeae13d61a3f6ba142d8702b57c383 to your computer and use it in GitHub Desktop.
Save savyounts/aebeae13d61a3f6ba142d8702b57c383 to your computer and use it in GitHub Desktop.
Sav Deep Linking
Ok so currently when I test out my links in Android Studio with App Links Assistant my assetlinks.json is linked an verified but when I try to test it on my simulator, it breifly opens the app but then terminates. This seems to be the main error I'm getting "W/unknown:ReconnectingWebSocket: Couldn't connect to "ws://10.0.2.2:8081/message?device=Android%20SDK%20built%20for%20x86%20-%208.1.0%20-%20API%2027&app=com.digitalbureau.Breakingviews&clientid=DevSupportManagerImpl", will silently retry". It pretty much does that until it terminates.
Website files:
assetlinks.json
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.digitalbureau.Breakingviews",
"sha256_cert_fingerprints":
["E0:9F:87:B2:93:30:81:9E:41:AF:FE:17:88:DC:87:ED:9F:3B:9F:51:D8:70:D1:5D:45:E0:21:1B:14:CB:70:6D"]
}
},
{
"relation": ["delegate_permission/common.get_login_creds"],
"target": {
"namespace": "web",
"site": "https://dev.breakingviews.com"
}
},
{
"relation": ["delegate_permission/common.get_login_creds"],
"target": {
"namespace": "android_app",
"package_name": "com.digitalbureau.Breakingviews",
"sha256_cert_fingerprints":
["E0:9F:87:B2:93:30:81:9E:41:AF:FE:17:88:DC:87:ED:9F:3B:9F:51:D8:70:D1:5D:45:E0:21:1B:14:CB:70:6D"]
}
}]
Mobile:
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.digitalbureau.Breakingviews"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name=".MainApplication"
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme">
<meta-data
android:name="asset_statements"
android:resource="@string/asset_statements" />
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:launchMode="singleTask"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- Deep Linking App Links -->
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="dev.breakingviews.com" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="dev.breakingviews.com"
android:pathPattern="/category/columns" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="dev.breakingviews.com"
android:pathPattern="/category/features" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="dev.breakingviews.com"
android:pathPattern="/considered-view" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="dev.breakingviews.com"
android:pathPattern="/columns" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="dev.breakingviews.com"
android:pathPattern="/features" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<!-- Hockeyapp -->
<activity android:name="net.hockeyapp.android.UpdateActivity" />
<activity android:name="net.hockeyapp.android.FeedbackActivity" />
<meta-data
android:name="net.hockeyapp.android.appIdentifier"
android:value="713c8b71c6a64d9fa959ebedb173d7c9" />
<!-- Push Notification -->
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService" />
<service
android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<!-- End Push Notifications -->
</application>
</manifest>
MainActivity.java (this is very messy, I know)
package com.digitalbureau.Breakingviews;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import com.facebook.react.ReactActivity;
import org.devio.rn.splashscreen.SplashScreen;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
SplashScreen.show(this); // here
super.onCreate(savedInstanceState);
// ATTENTION: This was auto-generated to handle app links.
Intent appLinkIntent = getIntent();
String appLinkAction = appLinkIntent.getAction();
Uri appLinkData = appLinkIntent.getData();
handleIntent(getIntent());
}
public void onNewIntent(Intent intent) {
super.onNewIntent(intent);
handleIntent(intent);
}
private void handleIntent(Intent intent){
String appLinkAction = intent.getAction();
Uri appLinkData = intent.getData();
if (Intent.ACTION_VIEW.equals(appLinkAction) && appLinkData != null) {
String pageId = appLinkData.getLastPathSegment();
Uri appData = Uri.parse("https://breakingviews.com").buildUpon()
.appendPath(pageId).build();
Intent newIntent = new Intent(appLinkAction, appLinkData);
startActivity(newIntent);
}
}
protected String getMainComponentName() {
return "BreakingviewsMobile";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment