- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有一个非常基本的 PushNotification
代码,它应该在没有 URL 时打开一个 Activity ,并在有 URL 时打开一个 URL。但它在收到通知时不会打开 URL。
下面的代码
public class MyFirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService {
private static final String TAG = "FirebaseMessagingServic";
public MyFirebaseMessagingService() {}
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
if (remoteMessage.getData().size() > 0) {
Log.d(TAG, "Message data payload: " + remoteMessage.getData());
try {
JSONObject data = new JSONObject(remoteMessage.getData());
String jsonMessage = data.getString("extra_information");
Log.d(TAG, "onMessageReceived: \n" +
"Extra Information: " + jsonMessage);
} catch (JSONException e) {
e.printStackTrace();
}
}
if (remoteMessage.getNotification() != null) {
String title = remoteMessage.getNotification().getTitle();
String message = remoteMessage.getNotification().getBody();
String click_action = remoteMessage.getNotification().getClickAction();
Uri uri = remoteMessage.getNotification().getLink();
Log.d(TAG, "Message Notification Title: " + title);
Log.d(TAG, "Message Notification Body: " + message);
Log.d(TAG, "Message Notification click_action: " + click_action);
Log.d(TAG, "Message Notification url: " + uri);
}
}
@Override
public void onDeletedMessages() {}
private void sendNotification(String title, String messageBody, String click_action, Uri uri) {
Intent intent;
if (uri != null) {
intent = new Intent(Intent.ACTION_VIEW);
intent.setData(uri));
} else {
intent = new Intent(click_action);
}
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */ , intent,
0);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.app_logo_final)
.setContentTitle("PushNotification")
.setContentText(messageBody)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0 /* ID of notification */ , notificationBuilder.build());
}
}
我发送这样的通知:
{
"to": "/topics/NEWS",
"data": {
"extra_information": "This is some extra information"
},
"notification": {
"title": "Test title: http://www.google.com",
"body": "Test body: http://www.google.com",
"uri": "http://www.google.com",
"click_action": "MAIN_PAGE"
}
}
受其他线程的启发,我有:
Uri.parse("http://www.google.com")
,以检查它是否会在任何条件下打开 www.google.com,但它不会工作。sendNotification(title, message, click_action, uri);
。没用intent = new intent(Intent.ACTION_VIEW); intent.setData(uri));
。没用click_action
中的 ACTIVITY 替换为 URL。没用startActivity(intent)
在我的 list 中,我有:
<activity android: name = ".MainScreen">
<intent-filter>
<action android: name = "android.intent.action.MAIN"/>
<category android: name = "android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android: name = "MAIN_PAGE"/>
<category android: name = "android.intent.category.DEFAULT"/>
</intent-filter>
它现在所做的是打开这个 MAIN_PAGE。是否需要在 list 中添加其他内容才能打开链接?
编辑:我刚刚发现在 Postman 中我需要“链接”而不是“uri”。尽管如此,这并没有解决问题。通过在后台运行应用程序的情况下查看 Logcat,我在单击通知时得到了这个:
01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.view.Window$Callback.onPointerCaptureChanged, referenced from method android.support.v7.view.WindowCallbackWrapper.onPointerCaptureChanged
01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve interface method 16186: Landroid / view / Window$Callback;.onPointerCaptureChanged(Z) V
01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x72 at 0x0002
01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.view.Window$Callback.onProvideKeyboardShortcuts, referenced from method android.support.v7.view.WindowCallbackWrapper.onProvideKeyboardShortcuts
01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve interface method 16188: Landroid / view / Window$Callback;.onProvideKeyboardShortcuts(Ljava / util / List; Landroid / view / Menu; I) V
01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x72 at 0x0002
01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to find class referenced in signature(Landroid / view / SearchEvent;)
01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested
01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve interface method 16190: Landroid / view / Window$Callback;.onSearchRequested(Landroid / view / SearchEvent;) Z
01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x72 at 0x0002
01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode
01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve interface method 16194: Landroid / view / Window$Callback;.onWindowStartingActionMode(Landroid / view / ActionMode$Callback; I) Landroid / view / ActionMode;
01 - 26 16: 51: 28.668 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x72 at 0x0002
01 - 26 16: 51: 28.678 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations
01 - 26 16: 51: 28.678 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 811: Landroid / content / res / TypedArray;.getChangingConfigurations() I
01 - 26 16: 51: 28.678 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6e at 0x0002
01 - 26 16: 51: 28.678 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType
01 - 26 16: 51: 28.678 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 833: Landroid / content / res / TypedArray;.getType(I) I
01 - 26 16: 51: 28.678 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6e at 0x0008
01 - 26 16: 51: 28.688 1395 - 1395 / com.tabian.firebasepushnotifications V / FA: onActivityCreated
01 - 26 16: 51: 28.748 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.widget.FrameLayout.startActionModeForChild, referenced from method android.support.v7.widget.ActionBarContainer.startActionModeForChild
01 - 26 16: 51: 28.748 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 16655: Landroid / widget / FrameLayout;.startActionModeForChild(Landroid / view / View; Landroid / view / ActionMode$Callback; I) Landroid / view / ActionMode;
01 - 26 16: 51: 28.748 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6f at 0x0002
01 - 26 16: 51: 28.758 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.content.Context.getColorStateList, referenced from method android.support.v7.content.res.AppCompatResources.getColorStateList
01 - 26 16: 51: 28.758 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 560: Landroid / content / Context;.getColorStateList(I) Landroid / content / res / ColorStateList;
01 - 26 16: 51: 28.758 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6e at 0x0006
01 - 26 16: 51: 28.768 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to find class referenced in signature(Landroid / graphics / drawable / Icon;)
01 - 26 16: 51: 28.768 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.widget.ImageButton.setImageIcon, referenced from method android.support.v7.widget.AppCompatImageButton.setImageIcon
01 - 26 16: 51: 28.768 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 16678: Landroid / widget / ImageButton;.setImageIcon(Landroid / graphics / drawable / Icon;) V
01 - 26 16: 51: 28.768 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6f at 0x0000
01 - 26 16: 51: 28.768 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawable
01 - 26 16: 51: 28.768 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 774: Landroid / content / res / Resources;.getDrawable(ILandroid / content / res / Resources$Theme;) Landroid / graphics / drawable / Drawable;
01 - 26 16: 51: 28.768 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6e at 0x0002
01 - 26 16: 51: 28.768 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawableForDensity
01 - 26 16: 51: 28.768 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 776: Landroid / content / res / Resources;.getDrawableForDensity(IILandroid / content / res / Resources$Theme;) Landroid / graphics / drawable / Drawable;
01 - 26 16: 51: 28.768 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6e at 0x0002
01 - 26 16: 51: 28.778 1395 - 1395 / com.tabian.firebasepushnotifications E / dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
01 - 26 16: 51: 28.778 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve instanceof 210(Landroid / graphics / drawable / RippleDrawable;) in Landroid / support / v7 / widget / AppCompatImageHelper;
01 - 26 16: 51: 28.778 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x20 at 0x000c
01 - 26 16: 51: 28.788 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.widget.TextView.getAutoSizeMaxTextSize, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeMaxTextSize
01 - 26 16: 51: 28.788 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 16974: Landroid / widget / TextView;.getAutoSizeMaxTextSize() I
01 - 26 16: 51: 28.788 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6f at 0x0006
01 - 26 16: 51: 28.788 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.widget.TextView.getAutoSizeMinTextSize, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeMinTextSize
01 - 26 16: 51: 28.788 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 16975: Landroid / widget / TextView;.getAutoSizeMinTextSize() I
01 - 26 16: 51: 28.788 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6f at 0x0006
01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.widget.TextView.getAutoSizeStepGranularity, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeStepGranularity
01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 16976: Landroid / widget / TextView;.getAutoSizeStepGranularity() I
01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6f at 0x0006
01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.widget.TextView.getAutoSizeTextAvailableSizes, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeTextAvailableSizes
01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 16977: Landroid / widget / TextView;.getAutoSizeTextAvailableSizes()[I 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6f at 0x0006 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.widget.TextView.getAutoSizeTextType, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeTextType 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 16978: Landroid / widget / TextView;.getAutoSizeTextType() I 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6f at 0x0008 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.widget.TextView.setAutoSizeTextTypeUniformWithConfiguration, referenced from method android.support.v7.widget.AppCompatTextView.setAutoSizeTextTypeUniformWithConfiguration 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 17021: Landroid / widget / TextView;.setAutoSizeTextTypeUniformWithConfiguration(IIII) V 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6f at 0x0006 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.widget.TextView.setAutoSizeTextTypeUniformWithPresetSizes, referenced from method android.support.v7.widget.AppCompatTextView.setAutoSizeTextTypeUniformWithPresetSizes 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 17022: Landroid / widget / TextView;.setAutoSizeTextTypeUniformWithPresetSizes([II) V 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6f at 0x0006 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.widget.TextView.setAutoSizeTextTypeWithDefaults, referenced from method android.support.v7.widget.AppCompatTextView.setAutoSizeTextTypeWithDefaults 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 17023: Landroid / widget / TextView;.setAutoSizeTextTypeWithDefaults(I) V 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6f at 0x0006 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.widget.TextView.getAutoSizeStepGranularity, referenced from method android.support.v7.widget.AppCompatTextHelper.loadFromAttributes 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 16976: Landroid / widget / TextView;.getAutoSizeStepGranularity() I 01 - 26 16: 51: 28.798 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6e at 0x0197 01 - 26 16: 51: 28.808 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.text.StaticLayout$Builder.obtain, referenced from method android.support.v7.widget.AppCompatTextViewAutoSizeHelper.createStaticLayoutForMeasuring 01 - 26 16: 51: 28.808 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve static method 15457: Landroid / text / StaticLayout$Builder;.obtain(Ljava / lang / CharSequence; IILandroid / text / TextPaint; I) Landroid / text / StaticLayout$Builder; 01 - 26 16: 51: 28.808 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x71 at 0x0014 01 - 26 16: 51: 28.828 1395 - 1409 / com.tabian.firebasepushnotifications V / FA: Connecting to remote service 01 - 26 16: 51: 28.848 1395 - 1409 / com.tabian.firebasepushnotifications V / FA: Activity resumed, time: 242636715 01 - 26 16: 51: 28.848 1395 - 1409 / com.tabian.firebasepushnotifications I / FA: Tag Manager is not found and thus will not be used 01 - 26 16: 51: 28.848 1395 - 1409 / com.tabian.firebasepushnotifications D / FA: Logging event(FE): screen_view(_vs), Bundle[{
firebase_event_origin(_o) = auto,
firebase_screen_class(_sc) = Main_Screen,
firebase_screen_id(_si) = 6213183756703048966
}] 01 - 26 16: 51: 28.858 1395 - 1395 / com.tabian.firebasepushnotifications I / Adreno - EGL: < qeglDrvAPI_eglInitialize: 381 >: EGL 1.4 QUALCOMM build: (CL3869936) OpenGL ES Shader Compiler Version: 17.01 .12.SPL Build Date: 03 / 03 / 14 Mon Local Branch: default Remote Branch:
Local Patches:
Reconstruct Branch:
01 - 26 16: 51: 28.918 1395 - 1395 / com.tabian.firebasepushnotifications D / OpenGLRenderer: Enabling debug mode 0 01 - 26 16: 51: 28.948 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to find class referenced in signature(Landroid / graphics / drawable / Icon;) 01 - 26 16: 51: 28.948 1395 - 1395 / com.tabian.firebasepushnotifications I / dalvikvm: Could not find method android.widget.ImageView.setImageIcon, referenced from method android.support.v7.widget.AppCompatImageView.setImageIcon 01 - 26 16: 51: 28.948 1395 - 1395 / com.tabian.firebasepushnotifications W / dalvikvm: VFY: unable to resolve virtual method 16713: Landroid / widget / ImageView;.setImageIcon(Landroid / graphics / drawable / Icon;) V 01 - 26 16: 51: 28.948 1395 - 1395 / com.tabian.firebasepushnotifications D / dalvikvm: VFY: replacing opcode 0x6f at 0x0000 01 - 26 16: 51: 28.948 1395 - 1409 / com.tabian.firebasepushnotifications V / FA: Connection attempt already in progress 01 - 26 16: 51: 29.018 1395 - 1409 / com.tabian.firebasepushnotifications D / FA: Connected to remote service 01 - 26 16: 51: 29.018 1395 - 1409 / com.tabian.firebasepushnotifications V / FA: Processing queued up service tasks: 2 01 - 26 16: 51: 31.871 1395 - 1395 / com.tabian.firebasepushnotifications I / PersonaManager: getPersonaService() name persona_policy 01 - 26 16: 51: 31.881 1395 - 1395 / com.tabian.firebasepushnotifications V / FA: onActivityCreated 01 - 26 16: 51: 31.911 1395 - 1409 / com.tabian.firebasepushnotifications V / FA: Recording user engagement, ms: 2928 01 - 26 16: 51: 31.911 1395 - 1409 / com.tabian.firebasepushnotifications V / FA: Activity paused, time: 242639638 01 - 26 16: 51: 31.931 1395 - 1409 / com.tabian.firebasepushnotifications D / FA: Logging event(FE): user_engagement(_e), Bundle[{
firebase_event_origin(_o) = auto,
engagement_time_msec(_et) = 2928,
firebase_screen_class(_sc) = Main_Screen,
firebase_screen_id(_si) = 6213183756703048966
}] 01 - 26 16: 51: 31.941 1395 - 1395 / com.tabian.firebasepushnotifications E / ViewRootImpl: sendUserActionEvent() mView == null 01 - 26 16: 51: 32.091 1395 - 1409 / com.tabian.firebasepushnotifications V / FA: Activity resumed, time: 242639824 01 - 26 16: 51: 37.097 1395 - 1409 / com.tabian.firebasepushnotifications V / FA: Inactivity, disconnecting from the service
当应用程序打开时,当我发送通知时,它会显示:
01 - 26 16: 53: 29.096 1395 - 2149 / com.tabian.firebasepushnotifications D / FirebaseMessagingServic: Message data payload: {
extra_information = This is some extra information
}
01 - 26 16: 53: 29.096 1395 - 2149 / com.tabian.firebasepushnotifications D / FirebaseMessagingServic: onMessageReceived:
Extra Information: This is some extra information
01 - 26 16: 53: 29.096 1395 - 2149 / com.tabian.firebasepushnotifications D / FirebaseMessagingServic: Message Notification Title: Test title: http: //www.google.com
01 - 26 16: 53: 29.096 1395 - 2149 / com.tabian.firebasepushnotifications D / FirebaseMessagingServic: Message Notification Body: Test body: http: //www.google.com
01 - 26 16: 53: 29.096 1395 - 2149 / com.tabian.firebasepushnotifications D / FirebaseMessagingServic: Message Notification click_action: MAIN_PAGE
01 - 26 16: 53: 29.106 1395 - 2149 / com.tabian.firebasepushnotifications D / FirebaseMessagingServic: Message Notification url: http: //www.google.com
01 - 26 16: 53: 35.293 1395 - 1395 / com.tabian.firebasepushnotifications I / PersonaManager: getPersonaService() name persona_policy
01 - 26 16: 53: 35.313 1395 - 1395 / com.tabian.firebasepushnotifications V / FA: onActivityCreated
01 - 26 16: 53: 35.353 1395 - 1395 / com.tabian.firebasepushnotifications E / ViewRootImpl: sendUserActionEvent() mView == null
01 - 26 16: 53: 35.353 1395 - 1845 / com.tabian.firebasepushnotifications V / FA: Recording user engagement, ms: 16086
01 - 26 16: 53: 35.353 1395 - 1845 / com.tabian.firebasepushnotifications V / FA: Connecting to remote service
01 - 26 16: 53: 35.383 1395 - 1845 / com.tabian.firebasepushnotifications V / FA: Activity paused, time: 242763126
01 - 26 16: 53: 35.383 1395 - 1845 / com.tabian.firebasepushnotifications V / FA: Connection attempt already in progress
01 - 26 16: 53: 35.383 1395 - 1845 / com.tabian.firebasepushnotifications V / FA: Activity resumed, time: 242763247
01 - 26 16: 53: 35.383 1395 - 1845 / com.tabian.firebasepushnotifications D / FA: Logging event(FE): user_engagement(_e), Bundle[{
firebase_event_origin(_o) = auto,
engagement_time_msec(_et) = 16086,
firebase_screen_class(_sc) = Main_Screen,
firebase_screen_id(_si) = 6213183756703048969
}]
01 - 26 16: 53: 35.423 1395 - 1845 / com.tabian.firebasepushnotifications V / FA: Connection attempt already in progress
01 - 26 16: 53: 35.493 1395 - 1845 / com.tabian.firebasepushnotifications D / FA: Connected to remote service
01 - 26 16: 53: 35.493 1395 - 1845 / com.tabian.firebasepushnotifications V / FA: Processing queued up service tasks: 3
最佳答案
您正在推送 json 中发送 notification
负载。这将使 onMessageReceived
不被调用。
来自 firebase 文档(https://firebase.google.com/docs/cloud-messaging/android/receive?hl=en):
onMessageReceived
is provided for most message types, with the following exceptions:
- Notification messages delivered when your app is in the background. In this case, the notification is delivered to the device’s system tray. A user tap on a notification opens the app launcher by default.
- Messages with both notification and data payload, both background and foreground. In this case, the notification is delivered to the device’s system tray, and the data payload is delivered in the extras of the intent of your launcher Activity.
所以如果你想自己处理通知,你应该只发送data
payload。
此外,在您的代码中,您不会在任何地方调用 sendNotification(String title, String messageBody, String click_action, Uri uri)
。
sendNotification
实现是正确的并且工作正常。你只是忘了在 onMessageReceived
中调用它!!
编辑:
要获取data
负载,您应该使用remoteMessage.getData()
而不是remoteMessage.getNotification()
关于java - 推送网址打不开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48463276/
我正在通过 NodeSchool.io 练习学习 React 和 Express 框架。 我想将所有练习文件存储在具有多个页面的单个应用程序中,例如 索引 索引2 索引3 索引4 .... local
从这里:http://developer.android.com/reference/android/os/AsyncTask.html doInBackground(URL... urls) onP
我最近收到了一封电子邮件,其中包含以下内容(请勿点击!): UNS 这是原始电子邮件的链接:https://gist.github.com/anonymous/16963a230cab0a3a1bc
在 android 中,可以单击带有 URL 的 TextView 以在网络中打开 URL,方法是: android:autoLink="web" 我想做的是捕获这次点击,如果这个 TextView
我在我的网站上以 mysite.anotherdomain.org 的形式实现 Facebook 登录。我在 JavaScript SDK 的文档中做了所有解释,但由于我遇到了一些问题,我想知道错误是
我在 window.location.href 中有响应网址,我需要其中的 error、error_description 和 state 的值 http://localhost:4200/#erro
我正在创建无限加载,意味着当用户到达页面底部/特定 div 时会加载新页面。目前我有这个代码可以在点击时加载新页面。 $("#about").click(function(){ // load
当我们在谷歌引擎中搜索时,它也会显示热门网站标签或链接。就像我们搜索“bing”或“net beans”时一样。 问:它如何显示这些链接。我们是否必须告诉它显示这些链接。 问:它是否与 sitemap
我想从我的网址中获取我的产品。例如: http://www.website.com/product-category/iphone 我想获取 iphone,这对我的代码来说没问题,但我有一个下拉菜单来
我对 Pythonanywhere 完全陌生,我不知道为什么静态文件没有加载...这是我存储 css 和图像的路径,即 static/images/wikiLang.png 等 /static/adm
我正在使用这个正则表达式来验证 youtube 网址。 ^http:\/\/(?:www\.)?youtube.com\/watch\?(?=.*v=\w+)(?:\S+)?$ 它很好用。 但我有这个
我刚刚在 gist.github 上传了一个我正在处理的小编码项目,因为它似乎是一次上传几个类的好方法。 我想将某人与我的“要点”联系起来,并在角落里写着: Public Clone URL: git
我正在使用 jQuery 验证引擎来解析我的表单数据: https://github.com/posabsolute/jQuery-Validation-Engine 验证 Twitter URL 的
我有一个 Django 应用程序,它可以在 localhost 上正常工作。即使对于 utf-8 URL 路径也是如此。但是当我在生产中使用它时,它给了我一个错误: 2019-09-01 14:32:
我已经安装了Laravel并开始尝试编写一个应用程序。我在/ app所在的目录中为 Assets 创建了一些目录。但是,当我尝试访问本地主机中的图像时,例如:http://localhost/asse
我们正在寻找一种方法来检查一长串 YouTube 网址,以查找目前私有(private)、已删除或不再可用的视频。我们可以检查状态,但即使视频不再公开可用,URL 也会返回 200。例如这两个: ht
我在 YouTube 上有现场事件,我想在我的网站上播放它。我想将我的事件设为私有(private),获取它的 RTMP 广播 URL 并将其粘贴到我的网站上,在 JWPlayer 中。 那可能吗?
当我在谷歌上搜索我的域时,它会显示我网站上的几个 https 网址,因为谷歌喜欢 https,但出于特殊原因我不想索引 https/ssl 版本。 如何避免这种情况,全世界都只通过 htaccess
我想获取在 Salesforce.com 授权期间作为回调收到的当前 URL。 url 中的数据位于片段部分。 最佳答案 您可以使用 $_SERVER['HTTP_HOST'] 和 $_SERVER[
我正在使用 ionic 创建一个应用程序,其中我使用 iframe 显示 URL。 这是 HTML 代码: 这是 Angular js: $scope.iframeHeight = windo
我是一名优秀的程序员,十分优秀!