Commit 922d915b authored by Sajal Narang's avatar Sajal Narang

Implement deep links for events

parent eaa478ab
...@@ -24,7 +24,8 @@ ...@@ -24,7 +24,8 @@
<meta-data <meta-data
android:name="com.google.firebase.messaging.default_notification_icon" android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_lotusgray" /> android:resource="@drawable/ic_lotusgray" />
<meta-data android:name="com.google.firebase.messaging.default_notification_color" <meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/colorPrimary" /> android:resource="@color/colorPrimary" />
<activity <activity
...@@ -61,6 +62,17 @@ ...@@ -61,6 +62,17 @@
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="insti.app"
android:pathPattern="/event/.*" />
</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 <data
android:scheme="http" android:scheme="http"
android:host="insti.app" android:host="insti.app"
...@@ -77,6 +89,17 @@ ...@@ -77,6 +89,17 @@
android:host="insti.app" android:host="insti.app"
android:pathPattern="/user/.*" /> android:pathPattern="/user/.*" />
</intent-filter> </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="http"
android:host="insti.app"
android:pathPattern="/event/.*" />
</intent-filter>
</activity> </activity>
<activity <activity
android:name=".LoginActivity" android:name=".LoginActivity"
...@@ -118,7 +141,7 @@ ...@@ -118,7 +141,7 @@
<meta-data <meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id" android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="@string/default_notification_channel_id"/> android:value="@string/default_notification_channel_id" />
</application> </application>
......
...@@ -168,6 +168,24 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -168,6 +168,24 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
case "user": case "user":
ProfileFragment profileFragment = ProfileFragment.newInstance(getID(appLinkData)); ProfileFragment profileFragment = ProfileFragment.newInstance(getID(appLinkData));
updateFragment(profileFragment); updateFragment(profileFragment);
break;
case "event":
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.getEvent(getSessionIDHeader(), getID(appLinkData)).enqueue(new Callback<Event>() {
@Override
public void onResponse(Call<Event> call, Response<Event> response) {
EventFragment eventFragment = new EventFragment();
Bundle bundle = new Bundle();
bundle.putString(Constants.EVENT_JSON, response.body().toString());
eventFragment.setArguments(bundle);
updateFragment(eventFragment);
}
@Override
public void onFailure(Call<Event> call, Throwable t) {
}
});
} }
} }
} }
...@@ -180,6 +198,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -180,6 +198,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
return appLinkData.substring(appLinkData.indexOf("org") + 4); return appLinkData.substring(appLinkData.indexOf("org") + 4);
case "user": case "user":
return appLinkData.substring(appLinkData.indexOf("user") + 5); return appLinkData.substring(appLinkData.indexOf("user") + 5);
case "event":
return appLinkData.substring(appLinkData.indexOf("event") + 6);
} }
return null; return null;
} }
...@@ -189,6 +209,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -189,6 +209,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
return "body"; return "body";
} else if (appLinkData.startsWith("http://insti.app/user/") || appLinkData.startsWith("https://insti.app/user/")) { } else if (appLinkData.startsWith("http://insti.app/user/") || appLinkData.startsWith("https://insti.app/user/")) {
return "user"; return "user";
} else if (appLinkData.startsWith("http://insti.app/event/") || appLinkData.startsWith("https://insti.app/event/")) {
return "event";
} }
return null; return null;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment