Skip to content

Commit

Permalink
Merge pull request #7 from jaewanLee/refactor/practice-branch
Browse files Browse the repository at this point in the history
Refactor/practice branch
  • Loading branch information
jaewanLee committed Nov 2, 2018
2 parents b876af3 + de27ba1 commit c730da1
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 19 deletions.
Expand Up @@ -49,14 +49,14 @@ public void onClick(View v) {
if (getIntent().getStringExtra("airbridgeLink") != null) {
redirectUrl = getIntent().getStringExtra("airbridgeLink");
Log.d(Config.TAG, "received PushMessage Data : " + redirectUrl);
String basicUrl = redirectUrl.substring(redirectUrl.indexOf("link=") + 5, redirectUrl.indexOf("&product"));
String productId = redirectUrl.substring(redirectUrl.indexOf("product_id") + 10, redirectUrl.indexOf("&airbridge"));
String basicUrl = redirectUrl.substring(redirectUrl.indexOf("webPage=") + 8, redirectUrl.indexOf("&apn"));
//TODO public void InAppTouchPointEvent();

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse("customtest://webview?value=" + basicUrl));
intent.putExtra("from", "pushMessage");
intent.putExtra("deeplinkUrl",redirectUrl);
startActivity(intent);

}
Expand All @@ -81,7 +81,7 @@ public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {
Log.d(Config.TAG, "Parsed Deeplink : " + deeplink);
deeplink = "customtest://webview?value=" + deeplink;
}
AirBridge.getTracker().sendEvent(new FirebaseDeeplinkEvent(String.valueOf(deeplink)));
AirBridge.getTracker().sendEvent(new FirebaseDeeplinkEvent(String.valueOf(dynamicLink)));
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse(deeplink));
Expand Down
Expand Up @@ -43,9 +43,8 @@ public void run() {

if (isFirst()) {
Intent intent = new Intent(IntroActivity.this, DialogActivity.class);
startActivityForResult(intent,1);
}
else{
startActivityForResult(intent, 1);
} else {
// 4초뒤에 다음화면(MainActivity)으로 넘어가기 Handler 사용
Intent intent = new Intent(getApplicationContext(), HomeActivtiy.class);
startActivity(intent); // 다음화면으로 넘어가기
Expand All @@ -67,10 +66,10 @@ public Boolean isFirst() {
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

switch (requestCode){
switch (requestCode) {
case 1:
if(resultCode==RESULT_OK){
Intent intent1=new Intent(IntroActivity.this,HomeActivtiy.class);
if (resultCode == RESULT_OK) {
Intent intent1 = new Intent(IntroActivity.this, HomeActivtiy.class);
startActivity(intent1);
finish();
break;
Expand Down
@@ -1,13 +1,17 @@
package org.airbloc.airbridgecustomtest;

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Build;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.support.v4.app.NotificationCompat;
Expand All @@ -29,24 +33,25 @@ public void onMessageReceived(RemoteMessage remoteMessage) {
Map<String, String> data = remoteMessage.getData();
String title = data.get("title");
String messagae = data.get("content");
String airbridgeLink=data.get("redirectLink");
String airbridgeLink = data.get("redirectLink");

Log.i(Config.TAG,"get Title : "+title);
Log.i(Config.TAG,"get Content : "+messagae);
Log.i(Config.TAG,"get RedirectLink : "+airbridgeLink);
Log.i(Config.TAG, "get Title : " + title);
Log.i(Config.TAG, "get Content : " + messagae);
Log.i(Config.TAG, "get RedirectLink : " + airbridgeLink);

sendNotification(title, messagae,airbridgeLink);
sendNotification(title, messagae, airbridgeLink);
}


private void sendNotification(String title, String message,String airbridgeLink) {
private void sendNotification(String title, String message, String airbridgeLink) {
Intent intent = new Intent(this, HomeActivtiy.class);
intent.putExtra("airbridgeLink",airbridgeLink);
intent.putExtra("airbridgeLink", airbridgeLink);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
PendingIntent.FLAG_CANCEL_CURRENT);

Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), android.R.drawable.ic_dialog_info))
.setSmallIcon(R.mipmap.ic_launcher)
Expand All @@ -56,7 +61,29 @@ private void sendNotification(String title, String message,String airbridgeLink)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

NotificationChannel notificationChannel = new NotificationChannel("CustomTester", "CustomTester Notification Channel", NotificationManager.IMPORTANCE_DEFAULT);
notificationChannel.setDescription("This Channel is engaged with CustomTester");
notificationChannel.enableLights(true);
notificationChannel.setLightColor(Color.GREEN);
notificationChannel.enableVibration(true);
notificationChannel.setVibrationPattern(new long[]{100, 200, 100, 200});
notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);

try{
assert notificationManager != null;
notificationManager.createNotificationChannel(notificationChannel);
notificationBuilder.setChannelId("CustomTester");
}catch (Exception e){
Log.d(Config.TAG,e.getMessage());
}

}

NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());

}
}
Expand Up @@ -23,11 +23,15 @@ protected void onCreate(Bundle savedInstanceState) {
// webView.loadUrl("https://airbridge.io");



if (DeepLink.hadOpened(this)) {
String deeplink = getIntent().getDataString();
if(getIntent().getStringExtra("from").equals("pushMessage"))
AirBridge.getTracker().sendEvent(new InAppTouchPointDeeplinkEvent(deeplink));
if (getIntent().getStringExtra("from").equals("pushMessage")) {
String redirectUrl = getIntent().getStringExtra("deeplinkUrl");
if (redirectUrl != null)
AirBridge.getTracker().sendEvent(new InAppTouchPointDeeplinkEvent(deeplink));

}


Log.d(Config.TAG, "WebVeiwActivity is opened with deeplink : " + deeplink);

Expand Down

0 comments on commit c730da1

Please sign in to comment.