Commit c0f39ef6 by sikang

remove firebase

parent 8232345e
......@@ -98,20 +98,22 @@ dependencies {
api 'com.squareup.retrofit2:converter-gson:2.4.0'
api 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
//firebase core
api 'com.google.firebase:firebase-core:16.0.3'
//firebase cloud message
api 'com.google.firebase:firebase-messaging:17.3.2'
// firebase core
// api 'com.google.firebase:firebase-core:16.0.3'
// firebase cloud message
// api 'com.google.firebase:firebase-messaging:17.3.2'
//firebase remoteConfig
// api 'com.google.firebase:firebase-config:16.0.0'
api 'com.android.installreferrer:installreferrer:1.0'
api 'com.google.android.gms:play-services-auth:15.0.1'
api 'com.google.android.gms:play-services-auth-api-phone:15.0.1'
api 'com.google.android.gms:play-services-ads:15.0.1'
//facebook accountKit SDK
api 'com.facebook.android:account-kit-sdk:4.37.0'
api 'com.google.android.gms:play-services-auth:15.0.1'
api 'com.google.android.gms:play-services-auth-api-phone:15.0.1'
//facebook SDK
// api 'com.facebook.android:facebook-android-sdk:[4,5)'
......
......@@ -22,24 +22,24 @@
android:name="android.max_aspect"
android:value="2.5" />
<!-- TODO - Firebase配置-->
<!--FireBase 推送-->
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="${CHANNEL_NAME}" />
<meta-data
android:name="firebase_messaging_auto_init_enabled"
android:value="false" />
<service android:name="com.common.service.MsgHandleService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name="com.common.service.MsgInstanceIdService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<!--<meta-data-->
<!--android:name="com.google.firebase.messaging.default_notification_channel_id"-->
<!--android:value="${CHANNEL_NAME}" />-->
<!--<meta-data-->
<!--android:name="firebase_messaging_auto_init_enabled"-->
<!--android:value="false" />-->
<!--<service android:name="com.common.service.MsgHandleService">-->
<!--<intent-filter>-->
<!--<action android:name="com.google.firebase.MESSAGING_EVENT" />-->
<!--</intent-filter>-->
<!--</service>-->
<!--<service android:name="com.common.service.MsgInstanceIdService">-->
<!--<intent-filter>-->
<!--<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />-->
<!--</intent-filter>-->
<!--</service>-->
<!--AutoSize-->
<meta-data
......
......@@ -10,14 +10,12 @@ import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import com.google.firebase.messaging.RemoteMessage;
import com.qmuiteam.qmui.util.QMUIStatusBarHelper;
import com.trello.rxlifecycle2.LifecycleTransformer;
import com.trello.rxlifecycle2.RxLifecycle;
......@@ -30,10 +28,8 @@ import tech.starwin.LibConfig;
import tech.starwin.R;
import tech.starwin.base.BasePresenter;
import com.common.service.MsgHandleService;
import tech.starwin.mvp.IView;
import tech.starwin.utils.LogUtils;
import tech.starwin.utils.context_utils.AppLanguageUtils;
import tech.starwin.utils.PresenterHoler;
import tech.starwin.utils.context_utils.FragmentLauncher;
......@@ -101,13 +97,14 @@ public abstract class BaseActivity extends AppCompatActivity implements IView {
@Override
protected void onStart() {
super.onStart();
//TODO - FireBase配置
//如果是通过FireBase CloudMessage 调起的界面,将消息交给Service处理
String action = getIntent().getAction() == null ? "" : getIntent().getAction();
String from = getIntent().getStringExtra("from");
if (action.equals("android.intent.action.MAIN") &&
!TextUtils.isEmpty(from)) {
MsgHandleService.handleMsg(this, new RemoteMessage(getIntent().getExtras()));
}
// String action = getIntent().getAction() == null ? "" : getIntent().getAction();
// String from = getIntent().getStringExtra("from");
// if (action.equals("android.intent.action.MAIN") &&
// !TextUtils.isEmpty(from)) {
// MsgHandleService.handleMsg(this, new RemoteMessage(getIntent().getExtras()));
// }
lifecycleSubject.onNext(ActivityEvent.START);
}
......
package com.common.service;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import com.trello.rxlifecycle2.LifecycleTransformer;
import com.trello.rxlifecycle2.android.ActivityEvent;
import org.greenrobot.eventbus.EventBus;
import javax.annotation.Nonnull;
import io.reactivex.Observable;
import tech.starwin.LibConfig;
import tech.starwin.mvp.IView;
import tech.starwin.mvp.presenter.UserPresenter;
import tech.starwin.utils.PreferencesManager;
import tech.starwin.utils.PresenterHoler;
import tech.starwin.utils.ui_utils.UIHelper;
/**
* Created by SiKang on 2018/9/27.
*/
public class MsgHandleService extends FirebaseMessagingService {
public static final String TAG = "MsgHandleService";
public static final String RECEIVED_FIREBASE_MESSAGE = "action.receivedFireBaseMessage";
@Override
public void onNewToken(String token) {
PreferencesManager.get().saveFireBaseMessagingToken(token);
new UserPresenter().uploadFirebaseToken(token);
}
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
handleMsg(this, remoteMessage);
if (remoteMessage.getNotification() != null) {
RemoteMessage.Notification notificationInfo = remoteMessage.getNotification();
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "default")
.setContentTitle(notificationInfo.getTitle())
.setContentText(notificationInfo.getBody())
.setSmallIcon(LibConfig.APP_ICON)
.setWhen(System.currentTimeMillis())
.setTicker(notificationInfo.getTitle())
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setAutoCancel(true);
UIHelper.notifyNotification(getBaseContext(), builder);
}
}
@Override
public void onDeletedMessages() {
}
/**
* 处理推送内容
*/
public static void handleMsg(Context context, RemoteMessage remoteMessage) {
if (remoteMessage != null) {
//EventBus 通知
EventBus.getDefault().post(remoteMessage);
//广播 通知
Intent intent = remoteMessage.toIntent();
intent.setAction(RECEIVED_FIREBASE_MESSAGE);
context.sendBroadcast(intent);
}
}
}
//package com.common.service;
//
//
//import android.content.Context;
//import android.content.Intent;
//import android.support.v4.app.NotificationCompat;
//
//import com.google.firebase.messaging.FirebaseMessagingService;
//import com.google.firebase.messaging.RemoteMessage;
//
//import org.greenrobot.eventbus.EventBus;
//
//import tech.starwin.LibConfig;
//import tech.starwin.mvp.presenter.UserPresenter;
//import tech.starwin.utils.PreferencesManager;
//import tech.starwin.utils.ui_utils.UIHelper;
//
//// TODO - Firebase配置
///**
// * Created by SiKang on 2018/9/27.
// */
//public class MsgHandleService extends FirebaseMessagingService {
// public static final String TAG = "MsgHandleService";
// public static final String RECEIVED_FIREBASE_MESSAGE = "action.receivedFireBaseMessage";
//
// @Override
// public void onNewToken(String token) {
// PreferencesManager.get().saveFireBaseMessagingToken(token);
// new UserPresenter().uploadFirebaseToken(token);
// }
//
// @Override
// public void onMessageReceived(RemoteMessage remoteMessage) {
// handleMsg(this, remoteMessage);
//
// if (remoteMessage.getNotification() != null) {
// RemoteMessage.Notification notificationInfo = remoteMessage.getNotification();
// NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "default")
// .setContentTitle(notificationInfo.getTitle())
// .setContentText(notificationInfo.getBody())
// .setSmallIcon(LibConfig.APP_ICON)
// .setWhen(System.currentTimeMillis())
// .setTicker(notificationInfo.getTitle())
// .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
// .setAutoCancel(true);
// UIHelper.notifyNotification(getBaseContext(), builder);
// }
// }
//
// @Override
// public void onDeletedMessages() {
// }
//
// /**
// * 处理推送内容
// */
// public static void handleMsg(Context context, RemoteMessage remoteMessage) {
// if (remoteMessage != null) {
// //EventBus 通知
// EventBus.getDefault().post(remoteMessage);
// //广播 通知
// Intent intent = remoteMessage.toIntent();
// intent.setAction(RECEIVED_FIREBASE_MESSAGE);
// context.sendBroadcast(intent);
// }
//
// }
//
//}
package com.common.service;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.FirebaseInstanceIdService;
import tech.starwin.utils.LogUtils;
/**
* Created by SiKang on 2018/9/27.
*/
public class MsgInstanceIdService extends FirebaseInstanceIdService {
public static final String TAG = "MsgInstanceIdService";
@Override
public void onTokenRefresh() {
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
LogUtils.d(TAG, "message token:" + refreshedToken);
}
}
//package com.common.service;
//
//import com.google.firebase.iid.FirebaseInstanceId;
//import com.google.firebase.iid.FirebaseInstanceIdService;
//
//import tech.starwin.utils.LogUtils;
//
///**
// * Created by SiKang on 2018/9/27.
// */
//// TODO - FireBase配置
//public class MsgInstanceIdService extends FirebaseInstanceIdService {
// public static final String TAG = "MsgInstanceIdService";
// @Override
// public void onTokenRefresh() {
// String refreshedToken = FirebaseInstanceId.getInstance().getToken();
// LogUtils.d(TAG, "message token:" + refreshedToken);
// }
//}
......@@ -6,7 +6,6 @@ import android.database.sqlite.SQLiteDatabase;
import android.text.TextUtils;
import android.view.View;
import com.google.firebase.FirebaseApp;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreator;
import com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreator;
......@@ -102,11 +101,10 @@ public class LibConfig {
//上传工具
UploadManager.init(CONTEXT);
//TODO - FireBase配置
//init FireBase
FirebaseApp.initializeApp(CONTEXT);
// FirebaseApp.initializeApp(CONTEXT);
//RemoteConfig
// initFirebaseRemoteConfig();
//init SharePreferences
PreferencesManager.get().init(CONTEXT);
......
......@@ -16,9 +16,7 @@ import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.internal.Util;
import tech.starwin.LibConfig;
import tech.starwin.R;
import tech.starwin.utils.LoginManager;
import tech.starwin.utils.PreferencesManager;
/**
* Created by XLEO on 2018/1/30.
......
......@@ -3,7 +3,6 @@ package tech.starwin.utils;
import android.util.Log;
import com.google.firebase.analytics.FirebaseAnalytics;
import tech.starwin.BuildConfig;
......
......@@ -7,7 +7,6 @@ import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.google.firebase.analytics.FirebaseAnalytics;
import tech.starwin.LibConfig;
......@@ -50,9 +49,10 @@ public class TrackEventHelper {
public static void logClickEventByName(Context context, String itemName) {
Bundle bundle = new Bundle();
String eventName = "click_" + itemName;
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, eventName);
//TODO - FireBase配置
// bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, eventName);
//FireBase 埋点
FirebaseAnalytics.getInstance(context).logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);
// FirebaseAnalytics.getInstance(context).logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);
if (onTrackEventListener != null) {
onTrackEventListener.onActionClick(eventName);
}
......@@ -62,8 +62,9 @@ public class TrackEventHelper {
* 行为埋点
*/
public static void logEvent(String eventName) {
//TODO - FireBase配置
//FireBase 埋点
FirebaseAnalytics.getInstance(LibConfig.getContext()).logEvent(eventName, null);
// FirebaseAnalytics.getInstance(LibConfig.getContext()).logEvent(eventName, null);
if (onTrackEventListener != null) {
onTrackEventListener.onActionEvent(eventName);
}
......
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