使用GCM推送通知

时间:2016-11-23 05:30:55

标签: android

我试图从服务器获取消息作为android中的推送通知。我能够点击服务器,但我收到了来自服务器的空消息。我可以在android中看到没有消息的通知。

这是我的代码

@Override
protected void onMessage(Context context, Intent intent) {

    if(aController == null)
        aController = (Controller) getApplicationContext();

    Log.i(TAG, "Received message");
    String message = intent.getExtras().getString("price");        
    aController.displayMessageOnScreen(context, message);
    // notifies user
    generateNotification(context, message);                                               
}

1 个答案:

答案 0 :(得分:0)

如果您使用module clockDivider(input logic input0, input logic input1, input logic clock, input logic reset, output logic y); // 00 = stop, 01 = slow, 10 = medium, 11 = fast; parameter mod = 2; reg [mod-1:0] count, max; assign y = ( ~input1 & ~input0 ) ? 1'b0 : count[mod-1]; /*stop clock*/ always @ (posedge clock) begin if( ~input1 & input0 ) /*slow*/ max <= (1 << (mod-2)) - 1'b1; else if( input1 & ~input0 ) /*medium*/ max <= (1 << (mod-1)) - 1'b1; else if( input1 & input0 ) /*fast*/ max <= (1 << mod) - 1'b1; end always @ (posedge clock, negedge reset) begin if (!reset) count <= 0; else if (count == max) count <= 0; else count <= count + 1'b1; end endmodule

GcmListenerService

即使我建议您使用FCM,因为GCM已被删除