diff --git a/README.md b/README.md index 801ca4f..86afa71 100644 --- a/README.md +++ b/README.md @@ -769,6 +769,13 @@ func main() { Platform: 2, Tokens: []string{"1234567890"}, Message: "test message", + Badge: 1, + Category: "test", + Alert: &proto.NotificationRequest_Alert{ + Title: "Test Title", + Body: "Test Alert Body", + Subtitle: "Test Alert Sub Title", + }, }) if err != nil { log.Fatalf("could not greet: %v", err) @@ -835,6 +842,13 @@ func main() { Platform: 2, Tokens: []string{"1234567890"}, Message: "test message", + Badge: 1, + Category: "test", + Alert: &proto.NotificationRequest_Alert{ + Title: "Test Title", + Body: "Test Alert Body", + Subtitle: "Test Alert Sub Title", + }, }) if err != nil { log.Fatalf("could not greet: %v", err) diff --git a/rpc/example/go/send/main.go b/rpc/example/go/send/main.go index ed138ec..0308920 100644 --- a/rpc/example/go/send/main.go +++ b/rpc/example/go/send/main.go @@ -26,6 +26,13 @@ func main() { Platform: 2, Tokens: []string{"1234567890"}, Message: "test message", + Badge: 1, + Category: "test", + Alert: &proto.NotificationRequest_Alert{ + Title: "Test Title", + Body: "Test Alert Body", + Subtitle: "Test Alert Sub Title", + }, }) if err != nil { log.Fatalf("could not greet: %v", err) diff --git a/rpc/example/node/gorush_grpc_pb.js b/rpc/example/node/gorush_grpc_pb.js index 0cf7099..d9b3abe 100644 --- a/rpc/example/node/gorush_grpc_pb.js +++ b/rpc/example/node/gorush_grpc_pb.js @@ -4,6 +4,28 @@ var grpc = require('grpc'); var gorush_pb = require('./gorush_pb.js'); +function serialize_proto_HealthCheckRequest(arg) { + if (!(arg instanceof gorush_pb.HealthCheckRequest)) { + throw new Error('Expected argument of type proto.HealthCheckRequest'); + } + return new Buffer(arg.serializeBinary()); +} + +function deserialize_proto_HealthCheckRequest(buffer_arg) { + return gorush_pb.HealthCheckRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_proto_HealthCheckResponse(arg) { + if (!(arg instanceof gorush_pb.HealthCheckResponse)) { + throw new Error('Expected argument of type proto.HealthCheckResponse'); + } + return new Buffer(arg.serializeBinary()); +} + +function deserialize_proto_HealthCheckResponse(buffer_arg) { + return gorush_pb.HealthCheckResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + function serialize_proto_NotificationReply(arg) { if (!(arg instanceof gorush_pb.NotificationReply)) { throw new Error('Expected argument of type proto.NotificationReply'); @@ -42,3 +64,18 @@ var GorushService = exports.GorushService = { }; exports.GorushClient = grpc.makeGenericClientConstructor(GorushService); +var HealthService = exports.HealthService = { + check: { + path: '/proto.Health/Check', + requestStream: false, + responseStream: false, + requestType: gorush_pb.HealthCheckRequest, + responseType: gorush_pb.HealthCheckResponse, + requestSerialize: serialize_proto_HealthCheckRequest, + requestDeserialize: deserialize_proto_HealthCheckRequest, + responseSerialize: serialize_proto_HealthCheckResponse, + responseDeserialize: deserialize_proto_HealthCheckResponse, + }, +}; + +exports.HealthClient = grpc.makeGenericClientConstructor(HealthService); diff --git a/rpc/example/node/gorush_pb.js b/rpc/example/node/gorush_pb.js index 816d428..a542b9b 100644 --- a/rpc/example/node/gorush_pb.js +++ b/rpc/example/node/gorush_pb.js @@ -9,8 +9,12 @@ var jspb = require('google-protobuf'); var goog = jspb; var global = Function('return this')(); +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. @@ -69,7 +73,10 @@ proto.proto.NotificationRequest.toObject = function(includeInstance, msg) { message: jspb.Message.getFieldWithDefault(msg, 3, ""), title: jspb.Message.getFieldWithDefault(msg, 4, ""), topic: jspb.Message.getFieldWithDefault(msg, 5, ""), - key: jspb.Message.getFieldWithDefault(msg, 6, "") + 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) }; if (includeInstance) { @@ -130,6 +137,19 @@ proto.proto.NotificationRequest.deserializeBinaryFromReader = function(msg, read var value = /** @type {string} */ (reader.readString()); msg.setKey(value); break; + case 7: + var value = /** @type {number} */ (reader.readInt32()); + msg.setBadge(value); + break; + case 8: + var value = /** @type {string} */ (reader.readString()); + msg.setCategory(value); + break; + case 9: + var value = new proto.proto.NotificationRequest.Alert; + reader.readMessage(value,proto.proto.NotificationRequest.Alert.deserializeBinaryFromReader); + msg.setAlert(value); + break; default: reader.skipField(); break; @@ -200,6 +220,222 @@ proto.proto.NotificationRequest.serializeBinaryToWriter = function(message, writ f ); } + f = message.getBadge(); + if (f !== 0) { + writer.writeInt32( + 7, + f + ); + } + f = message.getCategory(); + if (f.length > 0) { + writer.writeString( + 8, + f + ); + } + f = message.getAlert(); + if (f != null) { + writer.writeMessage( + 9, + f, + proto.proto.NotificationRequest.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_, 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); }; @@ -309,6 +545,66 @@ proto.proto.NotificationRequest.prototype.setKey = function(value) { }; +/** + * optional int32 badge = 7; + * @return {number} + */ +proto.proto.NotificationRequest.prototype.getBadge = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 7, 0)); +}; + + +/** @param {number} value */ +proto.proto.NotificationRequest.prototype.setBadge = function(value) { + jspb.Message.setField(this, 7, value); +}; + + +/** + * optional string category = 8; + * @return {string} + */ +proto.proto.NotificationRequest.prototype.getCategory = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 8, "")); +}; + + +/** @param {string} value */ +proto.proto.NotificationRequest.prototype.setCategory = function(value) { + jspb.Message.setField(this, 8, value); +}; + + +/** + * optional Alert alert = 9; + * @return {?proto.proto.NotificationRequest.Alert} + */ +proto.proto.NotificationRequest.prototype.getAlert = function() { + return /** @type{?proto.proto.NotificationRequest.Alert} */ ( + jspb.Message.getWrapperField(this, proto.proto.NotificationRequest.Alert, 9)); +}; + + +/** @param {?proto.proto.NotificationRequest.Alert|undefined} value */ +proto.proto.NotificationRequest.prototype.setAlert = function(value) { + jspb.Message.setWrapperField(this, 9, value); +}; + + +proto.proto.NotificationRequest.prototype.clearAlert = function() { + this.setAlert(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {!boolean} + */ +proto.proto.NotificationRequest.prototype.hasAlert = function() { + return jspb.Message.getField(this, 9) != null; +}; + + /** * Generated by JsPbCodeGenerator. @@ -478,4 +774,293 @@ proto.proto.NotificationReply.prototype.setCounts = function(value) { }; + +/** + * 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.HealthCheckRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.proto.HealthCheckRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.proto.HealthCheckRequest.displayName = 'proto.proto.HealthCheckRequest'; +} + + +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_, 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.HealthCheckRequest.prototype.toObject = function(opt_includeInstance) { + return proto.proto.HealthCheckRequest.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.HealthCheckRequest} msg The msg instance to transform. + * @return {!Object} + */ +proto.proto.HealthCheckRequest.toObject = function(includeInstance, msg) { + var f, obj = { + service: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + 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.HealthCheckRequest} + */ +proto.proto.HealthCheckRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.proto.HealthCheckRequest; + return proto.proto.HealthCheckRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.proto.HealthCheckRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.proto.HealthCheckRequest} + */ +proto.proto.HealthCheckRequest.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.setService(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.proto.HealthCheckRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.proto.HealthCheckRequest.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.HealthCheckRequest} message + * @param {!jspb.BinaryWriter} writer + */ +proto.proto.HealthCheckRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getService(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string service = 1; + * @return {string} + */ +proto.proto.HealthCheckRequest.prototype.getService = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** @param {string} value */ +proto.proto.HealthCheckRequest.prototype.setService = function(value) { + jspb.Message.setField(this, 1, value); +}; + + + +/** + * 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.HealthCheckResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.proto.HealthCheckResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.proto.HealthCheckResponse.displayName = 'proto.proto.HealthCheckResponse'; +} + + +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_, 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.HealthCheckResponse.prototype.toObject = function(opt_includeInstance) { + return proto.proto.HealthCheckResponse.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.HealthCheckResponse} msg The msg instance to transform. + * @return {!Object} + */ +proto.proto.HealthCheckResponse.toObject = function(includeInstance, msg) { + var f, obj = { + status: jspb.Message.getFieldWithDefault(msg, 1, 0) + }; + + 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.HealthCheckResponse} + */ +proto.proto.HealthCheckResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.proto.HealthCheckResponse; + return proto.proto.HealthCheckResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.proto.HealthCheckResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.proto.HealthCheckResponse} + */ +proto.proto.HealthCheckResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!proto.proto.HealthCheckResponse.ServingStatus} */ (reader.readEnum()); + msg.setStatus(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.proto.HealthCheckResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.proto.HealthCheckResponse.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.HealthCheckResponse} message + * @param {!jspb.BinaryWriter} writer + */ +proto.proto.HealthCheckResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStatus(); + if (f !== 0.0) { + writer.writeEnum( + 1, + f + ); + } +}; + + +/** + * @enum {number} + */ +proto.proto.HealthCheckResponse.ServingStatus = { + UNKNOWN: 0, + SERVING: 1, + NOT_SERVING: 2 +}; + +/** + * optional ServingStatus status = 1; + * @return {!proto.proto.HealthCheckResponse.ServingStatus} + */ +proto.proto.HealthCheckResponse.prototype.getStatus = function() { + return /** @type {!proto.proto.HealthCheckResponse.ServingStatus} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** @param {!proto.proto.HealthCheckResponse.ServingStatus} value */ +proto.proto.HealthCheckResponse.prototype.setStatus = function(value) { + jspb.Message.setField(this, 1, value); +}; + + goog.object.extend(exports, proto.proto); diff --git a/rpc/proto/gorush.pb.go b/rpc/proto/gorush.pb.go index fa7d0b2..2600e8a 100644 --- a/rpc/proto/gorush.pb.go +++ b/rpc/proto/gorush.pb.go @@ -62,12 +62,15 @@ func (HealthCheckResponse_ServingStatus) EnumDescriptor() ([]byte, []int) { } type NotificationRequest struct { - Tokens []string `protobuf:"bytes,1,rep,name=tokens" json:"tokens,omitempty"` - Platform int32 `protobuf:"varint,2,opt,name=platform" json:"platform,omitempty"` - Message string `protobuf:"bytes,3,opt,name=message" json:"message,omitempty"` - Title string `protobuf:"bytes,4,opt,name=title" json:"title,omitempty"` - Topic string `protobuf:"bytes,5,opt,name=topic" json:"topic,omitempty"` - Key string `protobuf:"bytes,6,opt,name=key" json:"key,omitempty"` + Tokens []string `protobuf:"bytes,1,rep,name=tokens" json:"tokens,omitempty"` + Platform int32 `protobuf:"varint,2,opt,name=platform" json:"platform,omitempty"` + Message string `protobuf:"bytes,3,opt,name=message" json:"message,omitempty"` + Title string `protobuf:"bytes,4,opt,name=title" json:"title,omitempty"` + Topic string `protobuf:"bytes,5,opt,name=topic" json:"topic,omitempty"` + Key string `protobuf:"bytes,6,opt,name=key" json:"key,omitempty"` + Badge int32 `protobuf:"varint,7,opt,name=badge" json:"badge,omitempty"` + Category string `protobuf:"bytes,8,opt,name=category" json:"category,omitempty"` + Alert *NotificationRequest_Alert `protobuf:"bytes,9,opt,name=alert" json:"alert,omitempty"` } func (m *NotificationRequest) Reset() { *m = NotificationRequest{} } @@ -117,6 +120,59 @@ func (m *NotificationRequest) GetKey() string { return "" } +func (m *NotificationRequest) GetBadge() int32 { + if m != nil { + return m.Badge + } + return 0 +} + +func (m *NotificationRequest) GetCategory() string { + if m != nil { + return m.Category + } + return "" +} + +func (m *NotificationRequest) GetAlert() *NotificationRequest_Alert { + if m != nil { + return m.Alert + } + return nil +} + +type NotificationRequest_Alert struct { + Title string `protobuf:"bytes,1,opt,name=title" json:"title,omitempty"` + Body string `protobuf:"bytes,2,opt,name=body" json:"body,omitempty"` + Subtitle string `protobuf:"bytes,3,opt,name=subtitle" json:"subtitle,omitempty"` +} + +func (m *NotificationRequest_Alert) Reset() { *m = NotificationRequest_Alert{} } +func (m *NotificationRequest_Alert) String() string { return proto1.CompactTextString(m) } +func (*NotificationRequest_Alert) ProtoMessage() {} +func (*NotificationRequest_Alert) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0, 0} } + +func (m *NotificationRequest_Alert) GetTitle() string { + if m != nil { + return m.Title + } + return "" +} + +func (m *NotificationRequest_Alert) GetBody() string { + if m != nil { + return m.Body + } + return "" +} + +func (m *NotificationRequest_Alert) GetSubtitle() string { + if m != nil { + return m.Subtitle + } + return "" +} + type NotificationReply struct { Success bool `protobuf:"varint,1,opt,name=success" json:"success,omitempty"` Counts int32 `protobuf:"varint,2,opt,name=counts" json:"counts,omitempty"` @@ -175,6 +231,7 @@ func (m *HealthCheckResponse) GetStatus() HealthCheckResponse_ServingStatus { func init() { proto1.RegisterType((*NotificationRequest)(nil), "proto.NotificationRequest") + proto1.RegisterType((*NotificationRequest_Alert)(nil), "proto.NotificationRequest.Alert") proto1.RegisterType((*NotificationReply)(nil), "proto.NotificationReply") proto1.RegisterType((*HealthCheckRequest)(nil), "proto.HealthCheckRequest") proto1.RegisterType((*HealthCheckResponse)(nil), "proto.HealthCheckResponse") @@ -320,28 +377,32 @@ var _Health_serviceDesc = grpc.ServiceDesc{ func init() { proto1.RegisterFile("gorush.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 353 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0xcf, 0x6e, 0x82, 0x40, - 0x10, 0xc6, 0x45, 0x05, 0x75, 0xec, 0x1f, 0xbb, 0x36, 0xcd, 0x96, 0x93, 0xe1, 0xc4, 0x89, 0x83, - 0xbd, 0xf5, 0x60, 0x9a, 0x34, 0x46, 0x9b, 0x26, 0x98, 0x2c, 0xfd, 0x73, 0x6c, 0x28, 0x1d, 0x95, - 0x88, 0x2c, 0x65, 0x97, 0x26, 0x3e, 0x47, 0x9f, 0xa0, 0x6f, 0xda, 0xec, 0x02, 0x4d, 0x4c, 0xe8, - 0x09, 0x7e, 0xdf, 0xec, 0x7e, 0xf3, 0xcd, 0x0e, 0x9c, 0x6c, 0x78, 0x5e, 0x88, 0xad, 0x97, 0xe5, - 0x5c, 0x72, 0x62, 0xea, 0x8f, 0xf3, 0x63, 0xc0, 0xd8, 0xe7, 0x32, 0x5e, 0xc7, 0x51, 0x28, 0x63, - 0x9e, 0x32, 0xfc, 0x2c, 0x50, 0x48, 0x72, 0x05, 0x96, 0xe4, 0x3b, 0x4c, 0x05, 0x35, 0x26, 0x1d, - 0x77, 0xc0, 0x2a, 0x22, 0x36, 0xf4, 0xb3, 0x24, 0x94, 0x6b, 0x9e, 0xef, 0x69, 0x7b, 0x62, 0xb8, - 0x26, 0xfb, 0x63, 0x42, 0xa1, 0xb7, 0x47, 0x21, 0xc2, 0x0d, 0xd2, 0xce, 0xc4, 0x70, 0x07, 0xac, - 0x46, 0x72, 0x09, 0xa6, 0x8c, 0x65, 0x82, 0xb4, 0xab, 0xf5, 0x12, 0xb4, 0xca, 0xb3, 0x38, 0xa2, - 0x66, 0xa5, 0x2a, 0x20, 0x23, 0xe8, 0xec, 0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62, 0x02, 0x00, - 0x00, + // 429 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xcf, 0x8e, 0x9b, 0x30, + 0x10, 0xc6, 0x97, 0x24, 0x90, 0x64, 0xd2, 0x3f, 0xe9, 0x6c, 0x55, 0xb9, 0x9c, 0x10, 0x27, 0x4e, + 0x1c, 0x52, 0xa9, 0x87, 0x1e, 0x56, 0xad, 0xaa, 0xd5, 0x6e, 0x55, 0x95, 0x95, 0x9c, 0xfe, 0x39, + 0x56, 0x84, 0xcc, 0x12, 0x14, 0x16, 0x53, 0x6c, 0x2a, 0xf1, 0x1c, 0x7d, 0xbb, 0x3e, 0x4d, 0x65, + 0x1b, 0xd2, 0x8d, 0x94, 0x9c, 0xf0, 0x6f, 0xfc, 0x79, 0xfc, 0x7d, 0x63, 0xe0, 0x49, 0x2e, 0x9a, + 0x56, 0xee, 0xe2, 0xba, 0x11, 0x4a, 0xa0, 0x6b, 0x3e, 0xe1, 0xdf, 0x11, 0x5c, 0x26, 0x42, 0x15, + 0xf7, 0x45, 0x96, 0xaa, 0x42, 0x54, 0x9c, 0x7e, 0xb5, 0x24, 0x15, 0xbe, 0x02, 0x4f, 0x89, 0x3d, + 0x55, 0x92, 0x39, 0xc1, 0x38, 0x9a, 0xf3, 0x9e, 0xd0, 0x87, 0x59, 0x5d, 0xa6, 0xea, 0x5e, 0x34, + 0x0f, 0x6c, 0x14, 0x38, 0x91, 0xcb, 0x0f, 0x8c, 0x0c, 0xa6, 0x0f, 0x24, 0x65, 0x9a, 0x13, 0x1b, + 0x07, 0x4e, 0x34, 0xe7, 0x03, 0xe2, 0x4b, 0x70, 0x55, 0xa1, 0x4a, 0x62, 0x13, 0x53, 0xb7, 0x60, + 0xaa, 0xa2, 0x2e, 0x32, 0xe6, 0xf6, 0x55, 0x0d, 0xb8, 0x84, 0xf1, 0x9e, 0x3a, 0xe6, 0x99, 0x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0x7f, 0x4a, 0x6e, 0x96, 0x0e, 0x3e, 0x87, 0x45, 0x72, 0xf7, 0xf5, 0xe7, + 0x50, 0x18, 0xad, 0x6e, 0xc1, 0xbb, 0x31, 0x3f, 0x20, 0x5e, 0xc1, 0x64, 0x4d, 0xd5, 0x16, 0xfd, + 0xf3, 0xcf, 0xe2, 0xb3, 0x93, 0x7b, 0x75, 0xd9, 0x85, 0x17, 0xba, 0x93, 0xb5, 0x8c, 0x57, 0xe0, + 0x1a, 0xdb, 0xf8, 0xfa, 0x54, 0x14, 0xdb, 0xc9, 0x3f, 0x9f, 0x72, 0xe3, 0x99, 0xad, 0x37, 0xff, + 0x02, 0x00, 0x00, 0xff, 0xff, 0x56, 0xd0, 0x68, 0x0d, 0x1b, 0x03, 0x00, 0x00, } diff --git a/rpc/proto/gorush.proto b/rpc/proto/gorush.proto index 70d317d..6f645cc 100644 --- a/rpc/proto/gorush.proto +++ b/rpc/proto/gorush.proto @@ -9,6 +9,14 @@ message NotificationRequest { string title = 4; string topic = 5; string key = 6; + int32 badge = 7; + string category = 8; + message Alert { + string title = 1; + string body = 2; + string subtitle = 3; + } + Alert alert = 9; } message NotificationReply { diff --git a/rpc/server.go b/rpc/server.go index 1ad0975..9d0445b 100644 --- a/rpc/server.go +++ b/rpc/server.go @@ -48,6 +48,7 @@ func (s *Server) Check(ctx context.Context, in *proto.HealthCheckRequest) (*prot // Send implements helloworld.GreeterServer func (s *Server) Send(ctx context.Context, in *proto.NotificationRequest) (*proto.NotificationReply, error) { + var badge = int(in.Badge) notification := gorush.PushNotification{ Platform: int(in.Platform), Tokens: in.Tokens, @@ -55,6 +56,13 @@ func (s *Server) Send(ctx context.Context, in *proto.NotificationRequest) (*prot Title: in.Title, Topic: in.Topic, APIKey: in.Key, + Category: in.Category, + Badge: &badge, + Alert: gorush.Alert{ + Title: in.Alert.Title, + Body: in.Alert.Body, + Subtitle: in.Alert.Subtitle, + }, } go gorush.SendNotification(notification)