Giter VIP home page Giter VIP logo

corona---onesignal-example's Introduction

Corona-OneSignal-Example

Corona and OneSignal example using REST API requests.

Instructions to use in your own project.

  1. Create an account and app in OneSignal.
  2. Follow the instructions here to set up Corona Notification: https://docs.coronalabs.com/plugin/notifications-v2/index.html.
  3. Copy and past notification.lua file from this repo to your project.
  4. Require the file at the top of your page:
local notify = require( "notification" )
  1. When testing call testing function. Remember to remove it before going live:
notify.isDevBuild()
  1. Initialize the library.
notify.init(
notifyListerner, --- Listerner you want to recieve the events.
  {
      appId = "", -- AppId from One Signal
      language = "en", -- Language. I use the candlelight plugin to get this, but you can also use "os.*" library.
      sessions = 23 -- I grab this from gamespark in my game but you can use a local variable you increment for every time they launch the app.
  }
) 
  1. iOS example:
Response: 	{
  "data":{
    "name":"notification",
    "type":"remote",
    "iosPayload": {..},
    "sound":"default",
    "alert":"hi. Hope you are doing well.",
    "applicationState":"inactive"
  },
  "name":"notify",
  "type":"remote"
}
  1. Android example:
Response: 	{
  "data":{
    "name":"notification",
    "type":"remote",
    "androidPayload": {..},
    "sound":"default",
    "alert":"hi. Hope you are doing well.",
    "applicationState":"inactive"
  },
  "name":"notify",
  "type":"remote"
}

Please note:

  1. The notification icons I created and you can reuse them if you want. I just drew a star in the middle of the appropiate sized image.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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.