Search in sources :

Example 1 with NotificationBean

use of com.benmu.framework.model.NotificationBean in project WeexErosFramework by bmfe.

the class ResultActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    if (intent == null || intent.getStringExtra("type") == null)
        return;
    String type = intent.getStringExtra("type");
    switch(type) {
        case Constant.Action.ACTION_NOTIFICATION:
            // 点击通知
            Serializable serializable = intent.getSerializableExtra(Constant.Notification.TAG_NOTIFICATION);
            if (serializable instanceof NotificationBean) {
                NotificationBean bean = (NotificationBean) serializable;
                // 发送事件
                Activity activity = RouterTracker.peekActivity();
                if (activity instanceof AbstractWeexActivity) {
                    WXSDKInstance wxsDkInstance = ((AbstractWeexActivity) activity).getWXSDkInstance();
                    GlobalEventManager.pushMessage(wxsDkInstance, com.benmu.framework.manager.impl.PushManager.getParams(bean, true));
                    finish();
                }
            }
            break;
    }
}
Also used : Serializable(java.io.Serializable) NotificationBean(com.benmu.framework.model.NotificationBean) WXSDKInstance(com.taobao.weex.WXSDKInstance) Activity(android.app.Activity) Intent(android.content.Intent)

Example 2 with NotificationBean

use of com.benmu.framework.model.NotificationBean in project WeexErosFramework by bmfe.

the class PushManager method handlePush.

public void handlePush(Context context, String data) {
    // 判断当前应用是在前台还是后台
    boolean isForeground = BaseCommonUtil.isAPPRunningForeground(context);
    ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
    NotificationBean bean = parseManager.parseObject(data, NotificationBean.class);
    if (isForeground) {
        // 在前台 通知js
        Activity activity = RouterTracker.peekActivity();
        if (activity instanceof AbstractWeexActivity) {
            WXSDKInstance instance = ((AbstractWeexActivity) activity).getWXSDkInstance();
            GlobalEventManager.pushMessage(instance, getParams(bean, false));
        }
    } else {
        // 在后台  显示通知
        showNotification(context, bean);
    }
}
Also used : NotificationBean(com.benmu.framework.model.NotificationBean) WXSDKInstance(com.taobao.weex.WXSDKInstance) ResultActivity(com.benmu.framework.activity.ResultActivity) AbstractWeexActivity(com.benmu.framework.activity.AbstractWeexActivity) Activity(android.app.Activity) AbstractWeexActivity(com.benmu.framework.activity.AbstractWeexActivity)

Aggregations

Activity (android.app.Activity)2 NotificationBean (com.benmu.framework.model.NotificationBean)2 WXSDKInstance (com.taobao.weex.WXSDKInstance)2 Intent (android.content.Intent)1 AbstractWeexActivity (com.benmu.framework.activity.AbstractWeexActivity)1 ResultActivity (com.benmu.framework.activity.ResultActivity)1 Serializable (java.io.Serializable)1