我想在 Node.js 中使用 FCM 添加推送通知的东西。为此我试过这个
我的 nodejs 代码
var FCM = require('fcm-node');
var serverkey = 'SERVERKEY';
var fcm = new FCM(serverkey);
var message = {
to : req.body.userToken,
collapse_key : 'XXX',
data : {
my_key: 'my value', contents: "abcv/"
},
notification : {
title : 'Title of the notification',
body : 'Body of the notification'
}
};
fcm.send(message, function(err,response){
if(err) {
console.log(message);
console.log("Something has gone wrong !");
} else {
console.log("Successfully sent with resposne :",response); …Run Code Online (Sandbox Code Playgroud)在我的 Android 应用程序中,我想将我的自定义对象传递给另一个活动。我正在使用 Intent
Intent i = new Intent(A.this,B.class);
i.putExtra ("Object", myObject);
context.startActivity (i);
Run Code Online (Sandbox Code Playgroud)
在调用活动中
MyObject myObject = (MyObject) intent.getSerializableExtra ("Object");
Run Code Online (Sandbox Code Playgroud)
我也在我的模型类中实现了 Serilizable。但是当我运行应用程序时它会显示
java.lang.RuntimeException: Parcelable 在写入可序列化对象时遇到 IOException
日志显示了这一点
java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.eventmate2.model.Event)
at android.os.Parcel.writeSerializable(Parcel.java:1394)
at android.os.Parcel.writeValue(Parcel.java:1341)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:644)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1313)
at android.os.Bundle.writeToParcel(Bundle.java:1034)
at android.os.Parcel.writeBundle(Parcel.java:669)
at android.content.Intent.writeToParcel(Intent.java:7501)
at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2479)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1496)
at android.app.Activity.startActivityForResult(Activity.java:3760)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:767)
at android.app.Activity.startActivityForResult(Activity.java:3721)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:754)
at android.app.Activity.startActivity(Activity.java:4033)
at android.app.Activity.startActivity(Activity.java:3999)
at com.eventmate2.adapter.HomeAdapter$2$1.onMenuItemClick(HomeAdapter.java:188)
at android.support.v7.widget.PopupMenu$1.onMenuItemSelected(PopupMenu.java:113)
at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:840)
at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:158)
at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:991)
at android.support.v7.view.menu.MenuPopup.onItemClick(MenuPopup.java:128) …Run Code Online (Sandbox Code Playgroud)