PDA

View Full Version : پیاده سازی Deep Link



Accidentboy
شنبه 10 فروردین 1398, 09:40 صبح
من تو پیاده سازی Deep link مشکل دارم هر کاری میکنم خطا میده..

الان مثلا دکمه تو اندروید میزنم میره سایت ش باز میشه بعدش بعد از تایید تو سایت چجوری صفحه بسته میشه و اطلاعات به سمت اندروید منتقل میشه؟

مثلا تو مانیفست




<activity android:name=".MainActivity">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<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="vosoli.ir"
android:pathPrefix="/quiz" />
</intent-filter>



اینم تو قسمت اکتیویتی



deeplink.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String url = "http://vosoli.ir/";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
}
});

public void onResume() {
super.onResume();
Log.i("TAG", "onCreate_onResume: " );

Intent intent = getIntent();
String action = intent.getAction();
Uri data = intent.getData();
Bundle bundle = intent.getExtras();
Uri uri = (Uri)bundle.get(Intent.EXTRA_STREAM);
Log.i("TAG", "onCreate_action: "+action.toString());
Log.i("TAG", "onCreate_url: "+uri.getQueryParameter("key"));


// check if this intent is started via custom scheme link
if (Intent.ACTION_VIEW.equals(intent.getAction()))
{
Uri uri1 = intent.getData();
// may be some test here with your custom uri
String key = uri1.getQueryParameter("key"); // "str" is set
Log.i("TAG", "onCreate_token: " + key);
}

}




اگه این درسته سمت سرورش باید چی کدی بنویستم؟

hharddy
شنبه 10 فروردین 1398, 13:50 عصر
سمت سرور کاری قرار نیست انجام بدید فقط url ایی که میخواید هروقت با باز شدن کاربر به اپلیکیشن منتقل بشه و مشخص میکنید
اگر هم میخواید یک سری اطلاعات به اپلیکیشن از این طریق بفرستید میتونید داخل url پارامتر های خودتون و بنویسید

Accidentboy
یک شنبه 11 فروردین 1398, 09:08 صبح
ممونم بابت راهنمایی تون