Giter Site home page Giter Site logo

csemrm / titaniumpush Goto Github PK

View Code? Open in Web Editor NEW

This project forked from realtime-framework/titaniumpush

0.0 3.0 0.0 14.35 MB

Titanium example for a cross-platform Realtime app using push notifications from GCM and APNS

License: MIT License

JavaScript 100.00%

titaniumpush's Introduction

Titanium Push Notifications with Realtime

This project shows how to build an Android and iOS Titanium app able to receive push notifications. This project uses the Realtime Titanium modules and Push Notifications from GCM and APNS.

Realtime + Android push notifications guide

  • Create a Google project, more info here.

  • Set the notification title to be displayed in the notification manager:

      ortc.setNotificationTitle('[App name for example]');
    
  • Before connect set your Google Project Number:

      ortc.setGoogleProjectId('462540995476');
      ortc.clusterUrl = 'http://ortc-developers.realtime.co/server/2.1';
      if(taAuthToken.value != '') {
      	ortc.connect(taAppKey.value, taAuthToken.value);
      } else {
      	ortc.connect(taAppKey.value);
      }
    
  • Set the onNotification eventListener:

      ortc.addEventListener('onNotification', function(e) {
      	addRowToEvents('(onNotification Channel: '+e.channel+') Message received: '+e.message+' Payload received: '+e.payload);
      	Titanium.API.log('(onNotification Channel: '+e.channel+') Message received: '+e.message);
      });
    
  • Use subscribeWithNotifications to subscribe the channel:

      ortc.subscribeWithNotifications(taChannel.value, true);
    
  • Add the following entries to your application TiApp.xml, replace [Titanium project identifier] :

      <android xmlns:android="http://schemas.android.com/apk/res/android">
          <manifest>
              <permission
                  android:name="[Titanium project identifier].permission.C2D_MESSAGE" android:protectionLevel="signature"/>
              <uses-permission android:name="[Titanium project identifier].permission.C2D_MESSAGE"/>
              <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
              <uses-permission
                  android:name="android.permission.GET_TASKS"/> //detect if app is running from service
              <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
              <uses-permission android:name="android.permission.WAKE_LOCK"/>
              <application android:debuggable="true">
                  <service android:name="co.realtime.ortc.BackgroundService"/>
                  <service android:name="ibt.ortc.extensibility.GcmOrtcIntentService"/>
                  <receiver
                      android:name="ibt.ortc.extensibility.GcmOrtcBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
                      <intent-filter>
                          <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
                          <action android:name="android.intent.action.BOOT_COMPLETED"/>
                          <category android:name="[Titanium project identifier]"/>
                      </intent-filter>
                      <intent-filter>
                          <action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
                          <category android:name="[Titanium project identifier]"/>
                          <action android:name="android.intent.action.BOOT_COMPLETED"/>
                      </intent-filter>
                  </receiver>
              </application>
          </manifest>
      </android>
    

Realtime + iOS push notifications guide

  • Setup iOS push notifications on iOS Dev Center, more info here.

  • Include 'co.realtime.ortc.apns.js' in your Titanium project.

  • Set the onNotification eventListener:

      ortc.addEventListener('onNotification', function(e) {
      	addRowToEvents('(onNotification Channel: '+e.channel+') Message received: '+e.message+' Payload received: '+e.payload);
      	Titanium.API.log('(onNotification Channel: '+e.channel+') Message received: '+e.message);
      });
    
  • Use subscribeWithNotifications to subscribe the channel:

      ortc.subscribeWithNotifications(taChannel.value, true);
    
  • On your run configuration set the application provision profile.

titaniumpush's People

Contributors

jparreira avatar realtime-framework avatar

Watchers

Mostafizur Rahman avatar James Cloos avatar  avatar

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.