fix(grpc): check alert exist. (#324)
* fix(grpc): check alert exist. * fix: update readme.
This commit is contained in:
@@ -28,7 +28,7 @@ func main() {
|
||||
Message: "test message",
|
||||
Badge: 1,
|
||||
Category: "test",
|
||||
Alert: &proto.NotificationRequest_Alert{
|
||||
Alert: &proto.Alert{
|
||||
Title: "Test Title",
|
||||
Body: "Test Alert Body",
|
||||
Subtitle: "Test Alert Sub Title",
|
||||
|
||||
@@ -7,12 +7,22 @@ function main() {
|
||||
var client = new services.GorushClient('localhost:9000',
|
||||
grpc.credentials.createInsecure());
|
||||
var request = new messages.NotificationRequest();
|
||||
var alert = new messages.Alert();
|
||||
request.setPlatform(2);
|
||||
request.setTokensList(["1234567890"]);
|
||||
request.setMessage("Hello!!");
|
||||
request.setTitle("hello2");
|
||||
request.setBadge(2);
|
||||
request.setCategory("mycategory");
|
||||
alert.setTitle("title");
|
||||
request.setAlert(alert);
|
||||
client.send(request, function (err, response) {
|
||||
console.log('Success:', response.getSuccess());
|
||||
console.log('Counts:', response.getCounts());
|
||||
if(err) {
|
||||
console.log(err);
|
||||
} else {
|
||||
console.log("Success:", response.getSuccess());
|
||||
console.log("Counts:", response.getCounts());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -9,12 +9,206 @@ var jspb = require('google-protobuf');
|
||||
var goog = jspb;
|
||||
var global = Function('return this')();
|
||||
|
||||
goog.exportSymbol('proto.proto.Alert', null, global);
|
||||
goog.exportSymbol('proto.proto.HealthCheckRequest', null, global);
|
||||
goog.exportSymbol('proto.proto.HealthCheckResponse', null, global);
|
||||
goog.exportSymbol('proto.proto.HealthCheckResponse.ServingStatus', null, global);
|
||||
goog.exportSymbol('proto.proto.NotificationReply', null, global);
|
||||
goog.exportSymbol('proto.proto.NotificationRequest', null, global);
|
||||
goog.exportSymbol('proto.proto.NotificationRequest.Alert', null, global);
|
||||
|
||||
/**
|
||||
* Generated by JsPbCodeGenerator.
|
||||
* @param {Array=} opt_data Optional initial data array, typically from a
|
||||
* server response, or constructed directly in Javascript. The array is used
|
||||
* in place and becomes part of the constructed object. It is not cloned.
|
||||
* If no data is provided, the constructed object will be empty, but still
|
||||
* valid.
|
||||
* @extends {jspb.Message}
|
||||
* @constructor
|
||||
*/
|
||||
proto.proto.Alert = function(opt_data) {
|
||||
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
|
||||
};
|
||||
goog.inherits(proto.proto.Alert, jspb.Message);
|
||||
if (goog.DEBUG && !COMPILED) {
|
||||
proto.proto.Alert.displayName = 'proto.proto.Alert';
|
||||
}
|
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) {
|
||||
/**
|
||||
* Creates an object representation of this proto suitable for use in Soy templates.
|
||||
* Field names that are reserved in JavaScript and will be renamed to pb_name.
|
||||
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
|
||||
* For the list of reserved names please see:
|
||||
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
|
||||
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
|
||||
* for transitional soy proto support: http://goto/soy-param-migration
|
||||
* @return {!Object}
|
||||
*/
|
||||
proto.proto.Alert.prototype.toObject = function(opt_includeInstance) {
|
||||
return proto.proto.Alert.toObject(opt_includeInstance, this);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Static version of the {@see toObject} method.
|
||||
* @param {boolean|undefined} includeInstance Whether to include the JSPB
|
||||
* instance for transitional soy proto support:
|
||||
* http://goto/soy-param-migration
|
||||
* @param {!proto.proto.Alert} msg The msg instance to transform.
|
||||
* @return {!Object}
|
||||
*/
|
||||
proto.proto.Alert.toObject = function(includeInstance, msg) {
|
||||
var f, obj = {
|
||||
title: jspb.Message.getFieldWithDefault(msg, 1, ""),
|
||||
body: jspb.Message.getFieldWithDefault(msg, 2, ""),
|
||||
subtitle: jspb.Message.getFieldWithDefault(msg, 3, "")
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
obj.$jspbMessageInstance = msg;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format).
|
||||
* @param {jspb.ByteSource} bytes The bytes to deserialize.
|
||||
* @return {!proto.proto.Alert}
|
||||
*/
|
||||
proto.proto.Alert.deserializeBinary = function(bytes) {
|
||||
var reader = new jspb.BinaryReader(bytes);
|
||||
var msg = new proto.proto.Alert;
|
||||
return proto.proto.Alert.deserializeBinaryFromReader(msg, reader);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format) from the
|
||||
* given reader into the given message object.
|
||||
* @param {!proto.proto.Alert} msg The message object to deserialize into.
|
||||
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
|
||||
* @return {!proto.proto.Alert}
|
||||
*/
|
||||
proto.proto.Alert.deserializeBinaryFromReader = function(msg, reader) {
|
||||
while (reader.nextField()) {
|
||||
if (reader.isEndGroup()) {
|
||||
break;
|
||||
}
|
||||
var field = reader.getFieldNumber();
|
||||
switch (field) {
|
||||
case 1:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setTitle(value);
|
||||
break;
|
||||
case 2:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setBody(value);
|
||||
break;
|
||||
case 3:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setSubtitle(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the message to binary data (in protobuf wire format).
|
||||
* @return {!Uint8Array}
|
||||
*/
|
||||
proto.proto.Alert.prototype.serializeBinary = function() {
|
||||
var writer = new jspb.BinaryWriter();
|
||||
proto.proto.Alert.serializeBinaryToWriter(this, writer);
|
||||
return writer.getResultBuffer();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the given message to binary data (in protobuf wire
|
||||
* format), writing to the given BinaryWriter.
|
||||
* @param {!proto.proto.Alert} message
|
||||
* @param {!jspb.BinaryWriter} writer
|
||||
*/
|
||||
proto.proto.Alert.serializeBinaryToWriter = function(message, writer) {
|
||||
var f = undefined;
|
||||
f = message.getTitle();
|
||||
if (f.length > 0) {
|
||||
writer.writeString(
|
||||
1,
|
||||
f
|
||||
);
|
||||
}
|
||||
f = message.getBody();
|
||||
if (f.length > 0) {
|
||||
writer.writeString(
|
||||
2,
|
||||
f
|
||||
);
|
||||
}
|
||||
f = message.getSubtitle();
|
||||
if (f.length > 0) {
|
||||
writer.writeString(
|
||||
3,
|
||||
f
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional string title = 1;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.proto.Alert.prototype.getTitle = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
|
||||
};
|
||||
|
||||
|
||||
/** @param {string} value */
|
||||
proto.proto.Alert.prototype.setTitle = function(value) {
|
||||
jspb.Message.setField(this, 1, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional string body = 2;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.proto.Alert.prototype.getBody = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, ""));
|
||||
};
|
||||
|
||||
|
||||
/** @param {string} value */
|
||||
proto.proto.Alert.prototype.setBody = function(value) {
|
||||
jspb.Message.setField(this, 2, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional string subtitle = 3;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.proto.Alert.prototype.getSubtitle = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, ""));
|
||||
};
|
||||
|
||||
|
||||
/** @param {string} value */
|
||||
proto.proto.Alert.prototype.setSubtitle = function(value) {
|
||||
jspb.Message.setField(this, 3, value);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generated by JsPbCodeGenerator.
|
||||
@@ -76,7 +270,7 @@ proto.proto.NotificationRequest.toObject = function(includeInstance, msg) {
|
||||
key: jspb.Message.getFieldWithDefault(msg, 6, ""),
|
||||
badge: jspb.Message.getFieldWithDefault(msg, 7, 0),
|
||||
category: jspb.Message.getFieldWithDefault(msg, 8, ""),
|
||||
alert: (f = msg.getAlert()) && proto.proto.NotificationRequest.Alert.toObject(includeInstance, f)
|
||||
alert: (f = msg.getAlert()) && proto.proto.Alert.toObject(includeInstance, f)
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
@@ -146,8 +340,8 @@ proto.proto.NotificationRequest.deserializeBinaryFromReader = function(msg, read
|
||||
msg.setCategory(value);
|
||||
break;
|
||||
case 9:
|
||||
var value = new proto.proto.NotificationRequest.Alert;
|
||||
reader.readMessage(value,proto.proto.NotificationRequest.Alert.deserializeBinaryFromReader);
|
||||
var value = new proto.proto.Alert;
|
||||
reader.readMessage(value,proto.proto.Alert.deserializeBinaryFromReader);
|
||||
msg.setAlert(value);
|
||||
break;
|
||||
default:
|
||||
@@ -239,206 +433,12 @@ proto.proto.NotificationRequest.serializeBinaryToWriter = function(message, writ
|
||||
writer.writeMessage(
|
||||
9,
|
||||
f,
|
||||
proto.proto.NotificationRequest.Alert.serializeBinaryToWriter
|
||||
proto.proto.Alert.serializeBinaryToWriter
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generated by JsPbCodeGenerator.
|
||||
* @param {Array=} opt_data Optional initial data array, typically from a
|
||||
* server response, or constructed directly in Javascript. The array is used
|
||||
* in place and becomes part of the constructed object. It is not cloned.
|
||||
* If no data is provided, the constructed object will be empty, but still
|
||||
* valid.
|
||||
* @extends {jspb.Message}
|
||||
* @constructor
|
||||
*/
|
||||
proto.proto.NotificationRequest.Alert = function(opt_data) {
|
||||
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
|
||||
};
|
||||
goog.inherits(proto.proto.NotificationRequest.Alert, jspb.Message);
|
||||
if (goog.DEBUG && !COMPILED) {
|
||||
proto.proto.NotificationRequest.Alert.displayName = 'proto.proto.NotificationRequest.Alert';
|
||||
}
|
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) {
|
||||
/**
|
||||
* Creates an object representation of this proto suitable for use in Soy templates.
|
||||
* Field names that are reserved in JavaScript and will be renamed to pb_name.
|
||||
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
|
||||
* For the list of reserved names please see:
|
||||
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
|
||||
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
|
||||
* for transitional soy proto support: http://goto/soy-param-migration
|
||||
* @return {!Object}
|
||||
*/
|
||||
proto.proto.NotificationRequest.Alert.prototype.toObject = function(opt_includeInstance) {
|
||||
return proto.proto.NotificationRequest.Alert.toObject(opt_includeInstance, this);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Static version of the {@see toObject} method.
|
||||
* @param {boolean|undefined} includeInstance Whether to include the JSPB
|
||||
* instance for transitional soy proto support:
|
||||
* http://goto/soy-param-migration
|
||||
* @param {!proto.proto.NotificationRequest.Alert} msg The msg instance to transform.
|
||||
* @return {!Object}
|
||||
*/
|
||||
proto.proto.NotificationRequest.Alert.toObject = function(includeInstance, msg) {
|
||||
var f, obj = {
|
||||
title: jspb.Message.getFieldWithDefault(msg, 1, ""),
|
||||
body: jspb.Message.getFieldWithDefault(msg, 2, ""),
|
||||
subtitle: jspb.Message.getFieldWithDefault(msg, 3, "")
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
obj.$jspbMessageInstance = msg;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format).
|
||||
* @param {jspb.ByteSource} bytes The bytes to deserialize.
|
||||
* @return {!proto.proto.NotificationRequest.Alert}
|
||||
*/
|
||||
proto.proto.NotificationRequest.Alert.deserializeBinary = function(bytes) {
|
||||
var reader = new jspb.BinaryReader(bytes);
|
||||
var msg = new proto.proto.NotificationRequest.Alert;
|
||||
return proto.proto.NotificationRequest.Alert.deserializeBinaryFromReader(msg, reader);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format) from the
|
||||
* given reader into the given message object.
|
||||
* @param {!proto.proto.NotificationRequest.Alert} msg The message object to deserialize into.
|
||||
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
|
||||
* @return {!proto.proto.NotificationRequest.Alert}
|
||||
*/
|
||||
proto.proto.NotificationRequest.Alert.deserializeBinaryFromReader = function(msg, reader) {
|
||||
while (reader.nextField()) {
|
||||
if (reader.isEndGroup()) {
|
||||
break;
|
||||
}
|
||||
var field = reader.getFieldNumber();
|
||||
switch (field) {
|
||||
case 1:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setTitle(value);
|
||||
break;
|
||||
case 2:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setBody(value);
|
||||
break;
|
||||
case 3:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setSubtitle(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the message to binary data (in protobuf wire format).
|
||||
* @return {!Uint8Array}
|
||||
*/
|
||||
proto.proto.NotificationRequest.Alert.prototype.serializeBinary = function() {
|
||||
var writer = new jspb.BinaryWriter();
|
||||
proto.proto.NotificationRequest.Alert.serializeBinaryToWriter(this, writer);
|
||||
return writer.getResultBuffer();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the given message to binary data (in protobuf wire
|
||||
* format), writing to the given BinaryWriter.
|
||||
* @param {!proto.proto.NotificationRequest.Alert} message
|
||||
* @param {!jspb.BinaryWriter} writer
|
||||
*/
|
||||
proto.proto.NotificationRequest.Alert.serializeBinaryToWriter = function(message, writer) {
|
||||
var f = undefined;
|
||||
f = message.getTitle();
|
||||
if (f.length > 0) {
|
||||
writer.writeString(
|
||||
1,
|
||||
f
|
||||
);
|
||||
}
|
||||
f = message.getBody();
|
||||
if (f.length > 0) {
|
||||
writer.writeString(
|
||||
2,
|
||||
f
|
||||
);
|
||||
}
|
||||
f = message.getSubtitle();
|
||||
if (f.length > 0) {
|
||||
writer.writeString(
|
||||
3,
|
||||
f
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional string title = 1;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.proto.NotificationRequest.Alert.prototype.getTitle = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
|
||||
};
|
||||
|
||||
|
||||
/** @param {string} value */
|
||||
proto.proto.NotificationRequest.Alert.prototype.setTitle = function(value) {
|
||||
jspb.Message.setField(this, 1, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional string body = 2;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.proto.NotificationRequest.Alert.prototype.getBody = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, ""));
|
||||
};
|
||||
|
||||
|
||||
/** @param {string} value */
|
||||
proto.proto.NotificationRequest.Alert.prototype.setBody = function(value) {
|
||||
jspb.Message.setField(this, 2, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional string subtitle = 3;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.proto.NotificationRequest.Alert.prototype.getSubtitle = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, ""));
|
||||
};
|
||||
|
||||
|
||||
/** @param {string} value */
|
||||
proto.proto.NotificationRequest.Alert.prototype.setSubtitle = function(value) {
|
||||
jspb.Message.setField(this, 3, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* repeated string tokens = 1;
|
||||
* If you change this array by adding, removing or replacing elements, or if you
|
||||
@@ -577,15 +577,15 @@ proto.proto.NotificationRequest.prototype.setCategory = function(value) {
|
||||
|
||||
/**
|
||||
* optional Alert alert = 9;
|
||||
* @return {?proto.proto.NotificationRequest.Alert}
|
||||
* @return {?proto.proto.Alert}
|
||||
*/
|
||||
proto.proto.NotificationRequest.prototype.getAlert = function() {
|
||||
return /** @type{?proto.proto.NotificationRequest.Alert} */ (
|
||||
jspb.Message.getWrapperField(this, proto.proto.NotificationRequest.Alert, 9));
|
||||
return /** @type{?proto.proto.Alert} */ (
|
||||
jspb.Message.getWrapperField(this, proto.proto.Alert, 9));
|
||||
};
|
||||
|
||||
|
||||
/** @param {?proto.proto.NotificationRequest.Alert|undefined} value */
|
||||
/** @param {?proto.proto.Alert|undefined} value */
|
||||
proto.proto.NotificationRequest.prototype.setAlert = function(value) {
|
||||
jspb.Message.setWrapperField(this, 9, value);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user