Giter VIP home page Giter VIP logo

gcm-playground's Introduction

Project status

status: inactive

This project is no longer actively maintained, and remains here as an archive of this work.

GCM Playground

A reference implementation of a GCM Application Server in the form of a playground that developers can use to test the Google Cloud Messaging Service.

Introduction

GCM Playground can be used to experiment sending and receiving messages with the Google Cloud Messaging API. The playground can be used as a sample implementation of the GCM App Server, that you can use as a reference for your own app server implementation.

What's Included

  • App Server (server/): Written in Go (Golang) is a GCM Application Server.
  • Playground UI (web/): Made with Polymer, it is the main component that you will for sending downstream messages and receiving upstream messages.
  • Client apps (android/, chrome/, web/): These client apps are used in conjunction with the playground UI to test various features of the GCM API.

Pre-requisites

Getting Started

Configuration

Before you can start using the GCM Playground you need to configure a project and create credentials for access:

  1. Follow this link to get a configuration file to use GCM.
  • If you want to use the Android client, configure your app to use com.google.samples.apps.gcmplayground for the package name. You can use a different package name if you want, but then you have to adapt the source code of the Android client accordingly. At the end of the configuration flow, download the configuration file to the android/app folder.
  • If you want to use the iOS client, use the bundle ID of an app that has the Push Notifications feature enabled, and upload its Development SSL Certificate when requested to do so. At the end of the configuration flow, download the configuration file to your machine.
  • If you want to use the Chrome App, just configure the project to use an Android client.
  1. After you enable Cloud Messaging, the configuration flow shows you your values of Server API Key and SenderId. Replace the placeholders value in server/server.go with the value you obtained:

server/server.go

// API key from Cloud console
apiKey = ""

// GCM sender ID
senderId = ""

web/app/settings.json

You should only need to change the IP address here. Replace 192.168.99.100 with the IP address that docker-machine ls gives you.

"main": {
  "sendMessageEndpoint": "http://192.168.99.100:4260/message",
  "clientsEndpoint": "http://192.168.99.100:4260/clients",
  "socketEndpoint": "http://192.168.99.100:4260/"
},

Installation - App Server and Playground UI

If the last command fails, you might need to give execute permission to the script. Do $ chmod +x start.sh and retry.

Accessing services - App Server and Playground UI

If using docker machine, run docker-machine ls to find out the VM IP address.

The ports that are being used are:

  • 3000 - Playground Web UI
  • 4260 - App server

So if your IP is 192.168.99.100, load 192.168.99.100:3000 in the browser of the computer running docker to access the Playground UI.

If you want to access the Playground Web UI using a mobile client instead of the computer running docker, you need to tunnel the app server traffic so it's accessible via the public network. To do that, download ngrok and run $ ./ngrok http <IP ADDRESS>:4260. Alternatively, you could also deploy the playground on any public cloud and use the server's address.

Android App

Included in android/ is an Android app that can help you get started with the playground. The Android app lets you:

  • Register and unregister the client with the backend.
  • Receive messages sent through the playground.
  • Subscribe to topics using Pubsub.
  • Send upstream messages.

Getting Started

  • Open Android Studio.
  • Select File > Open, browse to where you cloned the gcm-playground repository, and open the android folder (if you are in the Android Studio start screen, you can select Open an existing Android Studio project and use this same path).
  • Make sure that the configuration file is in the right place. Check the Configuration section above for instructions.

Usage

  • Run the sample on your Android device.
  • Provide a string identifier for your device (e.g. "My Nexus5"), and click REGISTER.
  • Use the playground web UI to send a message to the registered device.
  • A notification containing the GCM message should be displayed on the device.

iOS App

Included in ios/ is an iOS app that can help you get started with the playground. The iOS app lets you:

  • Register and unregister the client with the backend.
  • Receive messages sent through the playground.
  • Subscribe to topics using Pubsub.
  • Send upstream messages.

Getting Started

  • If you don't have CocoaPods installed on your machine, follow the instructions and istall it.
  • Open a terminal window and navigate to the gcm-playground/ios folder and run pod install.
  • Run open GCM Playground.xcworkspace to open the project in xcode.
  • In xcode, replace the project bundle ID with the bundle ID that you have used in the configuration flow.
  • In xcode, add the configuration file previously downloaded to the GCM Playground target. Check the Configuration section above for instructions.

Usage

  • Run the sample on your iOS device.
  • Provide a string identifier for your device (e.g. "My iphone6"), and click Register.
  • Use the playground web UI to send a message to the registered device.
  • A notification containing the GCM message should be displayed on the device.

Note: You need Swift 2.0 to run the app.

Chrome App

Included in chrome/ is a Chrome app that can help you get started with the playground. The Chrome app lets you:

  • Register the client with the backend
  • Receive messages sent through the playground

Usage

  • Open Chrome and go to menu > Tools > Extensions.
  • Click Developer mode > Load unpacked extensions...
  • Browse to and Select the chrome/ folder.
  • On the Extensions page, Launch GCM Playground Receiver app.

Support

If you've found an error in this sample, please file an issue: https://github.com/googlesamples/gcm-playground/issues

Patches are encouraged, and may be submitted by forking this project and submitting a pull request through GitHub.

License

Copyright 2015 Google, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

gcm-playground's People

Contributors

himattm avatar karan avatar naokigoogle avatar silvolu avatar urjitbhatia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gcm-playground's Issues

Playground should handle time-outs and errors

I've noticed that after sending a request, I can't seem to create a second one. I can go ahead and enter new text into the fields and it'll appear in the Request Body, but clicking on the "Send Message" button does nothing. I have to reload the entire page to send a second request.

I suspect this is related to issue #11 -- perhaps the page is waiting for some acknowledgement from the server before it "resets" to submit a second request, and if it's unable to communicate to the server, it's not getting back the acknowledgement it needs and therefore the page doesn't reset.

Server startup failure (type issues)

When I run ./start.sh I get the following output for the server:

server_1 | ./server.go:198: cannot use 10 (type int) as type string in field value

I tried changing the code from

m := gcm.XmppMessage{
    To:       token,
    Priority: 10,
    Data:     d,
}

to

m := gcm.XmppMessage{
    To:       token,
    Priority: "10",
    Data:     d,
}

to satisfy the type-checker. The server starts up just fine, but when trying to register the Android app as a client I get this error (formatted for readability)

server_1 |
    <message><data:gcm xmlns:data="google:mobile:data">
    {
        "message_type": "nack",
        "from": "...",
        "message_id": "...",
        "error": "INVALID_JSON",
        "error_description": "InvalidJson: JSON_TYPE_ERROR : Field \"priority\" must be a JSON an integer priority or a specific string (high or normal): 10"
    }
    </data:gcm></message>

I'm not sure what the solution is here, anybody have any help/suggestions?

README instructions aren't clear in regards to Docker

Your README instructions say:

You should only need to change the IP address here. Replace 192.168.99.100 with the IP address that docker-machine ls gives you.

However, docker-machine ls doesn't output anything except:
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS

GCM Priority value seems to be ignored

When I send a high-priority message from GCMPlayground to my iOS device, it shows up when the app is in the foreground, but not when the app is in the background.

On the other hand, when I send that same message using a CURL call, it shows up both when the app is in the foreground and in the background.

This suggests that GCMPlayground is somehow losing the priority value of the message somewhere along the way.

GCMPlayground doesn't seem to be talking to the server app

So I can load up my GCMPlayground page at ipAddress:3000, and I can create a request just fine. However, when I attempt to submit the request, it doesn't seem to talk to the server. I see the pop-up saying "Sending message", but message doesn't actually get sent.

There's nothing wrong with the request itself -- if I cut-and-paste the data into a curl call, everything works just fine.

My Chrome console is full of errors like
(index):1 XMLHttpRequest cannot load http://xxx.xxx.xx.xxx:2376/socket.io/?EIO=3&transport=polling&t=1445463292227-174. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://xxx.xxx.xx.xxx:3000' is therefore not allowed access. I'm going to guess that's probably related?

Unable to start app server

This is what I get in the terminal when I run ./start.sh

web_1 | [13:55:02] Finished 'jshint' after 1.9 s
web_1 | [13:55:02] Starting 'serve'...
web_1 | [13:55:02] Finished 'serve' after 235 ms
web_1 | [13:56:56] Starting 'jshint'...
web_1 | [13:56:57] Finished 'jshint' after 899 ms
web_1 | [13:56:58] Starting 'jshint'...
web_1 | [13:56:59] Finished 'jshint' after 1 s
server_1 |
server_1 |
server_1 |
server_1 |
server_1 |
server_1 |

and it goes on forever.

Need help!

GCM-playground is server is not loading

i can load gcm playground by access 192.168.99.100:3000 in chrome. it just display only "This page is not available " . and chrome console: "Failed to load resource: net::ERR_CONNECTION_REFUSED"
please help!!!

GCMPlayground doesn't load

I can't seem to get GCMPlayground to load on my chrome browser using the my server IP as per docker server IP i.e in my case http://192.168.100.99:3000 although I can see the server output on the terminal. I can register from Android and Chrome.

Remove TODOs from the Android client

MyActivity.java

    // TODO(karangoel): Remove these. Only for development purposes
    senderIdField.setText("1015367374593");
    stringIdentifierField.setText("Nexus 5");

Invalid key in checkin plist: GMSInstanceIDDeviceDataVersion

Hi!

I've set up the project as described in the readme file, but still am facing problems putting this example to work.
Have tried using development & production push notification certificates. Also went a second time throw the creation of the provision profile, certificate and configuration file, since some users reported these were the solutions for their issues.

When running the app, and trying to register a user, these are the logs i'm getting:

2016-05-16 00:00:16.144 GCM Playground[2537:] <GMR/INFO> App measurement v.2003000 started
2016-05-16 00:00:16.155 GCM Playground[2537:] <GMR/INFO> To enable debug logging set the following application argument: -GMRDebugEnabled (see http://goo.gl/Y0Yjwu)
2016-05-16 00:00:16.188: GCM | GCM library version 1.1.4
2016-05-16 00:00:16.209: GCM | Invalid key in checkin plist: GMSInstanceIDDeviceDataVersion
2016-05-16 00:00:16.926: GCM | Signing into MCS
2016-05-16 00:00:17.333 GCM Playground[2537:] <GMR/INFO> App measurement enabled
Connected to GCM
2016-05-16 00:00:21.695: GCM | Successfully deleted 0 sync messages from store
Sender text is Optional("<a_name_to_recognize_the_device>")
Registration Token: dj49yK3XMpA:APA91bGSyTaspk6todW7QZhDQa7Pf02QUuoIBxnHSzga9rSUmGLmgIvpVAoYiRpYHu13-ZbT2LGCh0j_1E5kHz2qCHma2E11v-Mj6hFSTH9Xu7VnU2IsNx4Bh1ICYAtlXTZYHPFbb_HV
2016-05-16 00:00:46.796: GCM | Sending message: {
    action = "register_new_client";
    "registration_token" = "dj49yK3XMpA:APA91bGSyTaspk6todW7QZhDQa7Pf02QUuoIBxnHSzga9rSUmGLmgIvpVAoYiRpYHu13-ZbT2LGCh0j_1E5kHz2qCHma2E11v-Mj6hFSTH9Xu7VnU2IsNx4Bh1ICYAtlXTZYHPFbb_HV";
    stringIdentifier = user11;
} with id: 1463353246.79399

I'm not getting any response to this new user registration request.
Bellow an app screen:
http://grab.by/Q9W0
Does anyone have a clue of what might be going on?

Thanks

TODO: Remove the sender ID

In your iOS ViewController, there's a line that says:

// TODO(karangoel): Remove this, only for development

senderIDField.text = "..."

You should probably remove that. I think it's only for development. :)

iOS App has Provisioning Profile hard-coded in

The project.pbxproj file has a PROVISIONING_PROFILE ID included. I'm guessing we probably want to remove that line (or set it to ""), since that will cause errors for other folks looking to use the app.

Message was sent with "Dry Run" switch turned on

I created a Single Device message (using XMPP, if that matters) in GCM Playground and had the "Dry run" option turned on. When I clicked the "Send message" button, my message got sent anyway.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.