{"id":4760,"url":"https://github.com/realtime-framework/RCTRealtimeMessagingAndroid","last_synced_at":"2025-08-04T02:31:35.518Z","repository":{"id":57339447,"uuid":"42862023","full_name":"realtime-framework/RCTRealtimeMessagingAndroid","owner":"realtime-framework","description":"Realtime Cloud Messaging React Native SDK for Android","archived":false,"fork":false,"pushed_at":"2017-11-23T15:59:42.000Z","size":51,"stargazers_count":50,"open_issues_count":1,"forks_count":13,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-07-29T19:44:12.826Z","etag":null,"topics":["android","push-notifications","react-native","realtime-messaging"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/realtime-framework.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-21T11:24:49.000Z","updated_at":"2025-02-22T16:52:23.000Z","dependencies_parsed_at":"2022-09-16T13:01:51.341Z","dependency_job_id":null,"html_url":"https://github.com/realtime-framework/RCTRealtimeMessagingAndroid","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/realtime-framework/RCTRealtimeMessagingAndroid","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realtime-framework%2FRCTRealtimeMessagingAndroid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realtime-framework%2FRCTRealtimeMessagingAndroid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realtime-framework%2FRCTRealtimeMessagingAndroid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realtime-framework%2FRCTRealtimeMessagingAndroid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/realtime-framework","download_url":"https://codeload.github.com/realtime-framework/RCTRealtimeMessagingAndroid/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realtime-framework%2FRCTRealtimeMessagingAndroid/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268639931,"owners_count":24282678,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-04T02:00:09.867Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","push-notifications","react-native","realtime-messaging"],"created_at":"2024-01-05T20:17:22.467Z","updated_at":"2025-08-04T02:31:35.259Z","avatar_url":"https://github.com/realtime-framework.png","language":"Java","readme":"# Realtime Messaging SDK for React-Native Android\n\n[Realtime Cloud Messaging](http://framework.realtime.co/messaging) is a highly-scalable pub/sub message broker, allowing you to broadcast messages to millions of users, reliably and securely. It's all in the cloud so you don't need to manage servers.\n\n[React Native](http://facebook.github.io/react-native/) enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and React.\n\n\nMore information can be found on the\n[Realtime native Android SDK reference documentation](http://messaging-public.realtime.co/documentation/android/2.1.0/index.html?ibt/ortc/api/Ortc.html).\n\n\n## Installation\n\n* Create a new react-native project. [Check react-native getting started](http://facebook.github.io/react-native/docs/getting-started.html#content)\n\n* Execute\n\n\t\t npm install --save react-native-realtimemessaging-android\n\n* In `android/settings.gradle`\n\n\t\t...\n\t\tinclude ':react-native-realtime-messaging-android'\n\t\tproject(':react-native-realtime-messaging-android').projectDir = new File(settingsDir,'../node_modules/react-native-realtimemessaging-android/reactnativemessagingandroid')\n\n* In `android/app/build.gradle`\n\n\t\t...\n\t\tdependencies {\n\t\t    ...\n\t\t    compile project(':react-native-realtime-messaging-android')\n\t\t}\n\n* Add `new RealtimeMessagingPackage()` to the `getPackages()` method return list in `MainApplication.java`.\n\n\t\timport co.realtime.reactnativemessagingandroid.RealtimeMessagingPackage; //\u003c-- import\n\n\t\tpublic class MainApplication extends Application implements ReactApplication {\n\n\t\t    ...\n\n\t\t    @Override\n\t\t    protected List\u003cReactPackage\u003e getPackages() {\n\t\t        return Arrays.\u003cReactPackage\u003easList(\n\t\t                new MainReactPackage(),\n\t\t                new RealtimeMessagingPackage() // \u003c-- add RealtimeMessagingPackage object\n\t\t        );\n\t\t    }\n\t\t   \n\t\t    ...\n\n\n\n\n* Drag `PROJECT_DIR/node_modules/react-native-realtimemessaging-android/RCTRealtimeMessagingAndroid.js` to the root of your project.\n\n* **If you want to use push notifications**, set `MainActivity` extending `RealtimePushNotificationActivity`.\n\n\t\timport co.realtime.reactnativemessagingandroid.RealtimePushNotificationActivity;\n\n\t\tpublic class MainActivity extends RealtimePushNotificationActivity {\n\t\t...\n\t\t}\n\n You are ready to go.\n\n---\n\n\n\n## RealtimeMessagingAndroid class reference\n\n### Import RealtimeMessaging to your project\n\n\timport realtime from './RCTRealtimeMessagingAndroid';\n\tvar RCTRealtimeMessaging = new realtime();\n\n### Event handling\n\nIn order to get event notifications from the native SDK, the JavaScript interface has two methods for adding and removing event registration.\n\n**RTEventListener(notification, callBack: Function)** \u003cbr\u003e\n\nRTEventListener registers a given event name on the ***notification*** field and a given ***callback function*** to be fired when the event occurs.\n\n***Example:***\n\n\timport realtime from './RCTRealtimeMessagingAndroid';\n\tvar RCTRealtimeMessaging = new realtime();\n\n\tRCTRealtimeMessaging.RTEventListener(\"onConnected\",this._onConnected),\n\n**RTRemoveEventListener(notification)**\n\nRTRemoveEventListener removes an event registration. After this method when the event occurs the ***callback*** will not be fired.\n\n***Example:***\n\n\timport realtime from './RCTRealtimeMessagingAndroid';\n\tvar RCTRealtimeMessaging = new realtime();\n\n\tRCTRealtimeMessaging.RTEventListener(\"onConnected\",this._onConnected),\n\tRCTRealtimeMessaging.RTRemoveEventListener(\"onConnected\"),\n\n\n\n***Complete event list:***\n\n* onConnected - Occurs when the client connects\n\n* onDisconnect - Occurs when the client disconnects\n\n* onReconnect - Occurs when the client reconnects\n\n* onReconnecting - Occurs when the client is attempting to reconnect\n\n* onSubscribed - Occurs when the client has successfully subscribed a channel. The event notification data is `{\"channel\":channel}`\n\n* onUnSubscribed - Occurs when the client has successfully unsubscribed a channel. The event notification data is `{\"channel\":channel}`\n\n* onException - Occurs when there is an exception. The event notification data is `{\"error\":error.localizedDescription}`\n\n* onMessage - Occurs when a message is received. The event notification data is `{\"message\": message,\"channel\": channel}`\n\n*\tonMessageWithFilter - Occurs when a message is received using `RTSubscribeWithFilter`. The event notification data is `{\"message\": message,\"channel\": channel, \"filtered\":true}`, where the filtered property indicates wheter the server was able to successfully filter the message. \n\n*\tonMessageWithBuffer - Fired when a message was received in the specified channel subscribed with the `RTSubscribeWithBuffer`.\n\t- channel - The channel where the message was received\n\t- seqId - The message sequence id\n\t- message - The message received\n\n*\tonMessageWithOptions - Fired when a message was received in the specified channel subscribed with the `RTSubscribeWithOptions`\n\t- msgOptions - Dictionary where the message data was received\n\t\n\t-\n\t\tmsgOptions = {\n\t\t    channel, // Channel where the message was received\n\t\t    seqId, // The message sequence id property\n\t\t    filtered, // Indicates if server has filtered the message\n\t\t    message // Content of the received message\n\t\t}\n\n\n* onPresence - Gets the subscriptions in the specified channel and if active the first 100 unique connection metadata:\n\t- On success -\u003e `{\"result\": result}`\n\t- On error -\u003e `{\"error\": error}`\n\n* onEnablePresence - Enables presence for the specified channel with the first 100 unique connection metadata:\n\t- On success -\u003e `{\"result\": result}`\n\t- On error -\u003e `{\"error\": error}`\n\n* onDisablePresence - Disables presence for the specified channel:\n\t- On success -\u003e `{\"result\": result}`\n\t- On error -\u003e `{\"error\": error}`\n\n### Push notification handling\n\n#### Configure your project for push notifications handling\n\nTo configure your react-native project to receive push notifications you must follow [this guide](http://messaging-public.realtime.co/documentation/starting-guide/mobilePushGCM.html) for the Android platform.\n\n\n#### Handling push notifications through javascript\n\nFor handling push notifications ( sent using the Realtime mobile push notifications REST API) we added the following event listener:\n\n* RTPushNotificationListener(callBack: Function)\n\n***Example:***\n\n\tcomponentDidMount: function(){\n  \t\tRCTRealtimeMessaging.RTCPushNotificationListener(this._onNotification);\n\t},\n\n\t_onNotification: function(data)\n\t{\n\t  this._log(\"Received notification: \" + JSON.stringify(data));  \n\t},\n\n----------\n\n### Methods\n\n##### RTConnect(config)\n\nConnects the client to Realtime server with the given configuration.\n\n**Parameters**\n\n* appkey - Realtime application key\n* token - Authentication token\n* connectionMetadata - Connection metadata string\n* clusterUrl or url - The Realtime Messaging cluster or server URL\n* projectId - The GCM project number, only required for push notifications usage\n\n***Example:***\n\n\tRCTRealtimeMessaging.RTEventListener(\"onConnected\",function(){\n\t\tconsole.log('Connected to Realtime Messaging');\n\t}),\n\n\tRCTRealtimeMessaging.RTConnect(\n    {\n      appKey:this.state.appKey,\n      token:this.state.token,\n      connectionMetadata:this.state.connectionMetadata,\n      clusterUrl:this.state.clusterUrl\n    });\n\n\n----------\n\n##### RTDisconnect()\n\nDisconnects the client from the Realtime server.\n\n***Example:***\n\n\tRCTRealtimeMessaging.RTEventListener(\"onDisconnect\", function(){\n\t\tconsole.log('Disconnected from Realtime Messaging');\n\t}),\n\n\tRCTRealtimeMessaging.RTDisconnect();\n\n----------\n\n##### RTSubscribe(channel, subscribeOnReconnect: boolean)\n\nSubscribes a pub/sub channel to receive messages.\n\n**Parameters**\n\n* channel - Channel name\n\n* subscribeOnReconnected -\nIndicates whether the client should subscribe the channel when reconnected (if it was previously subscribed when connected).\n\n***Example:***\n\n\tRCTRealtimeMessaging.RTEventListener(\"onSubscribed\", function(subscribedEvent){\n\t\tconsole.log('Subscribed channel: ' + subscribedEvent.channel);\n\t}),\n\n\tRCTRealtimeMessaging.RTSubscribe(\"MyChannel\", true);\n\n----------\n\n##### RTSubscribeWithFilter(channel, subscribeOnReconnect: boolean, filter)\n\nSubscribes a channel using a filter, to receive only messages that validate the filter.\n\n**Parameters**\n\n* channel - Channel name\n\n* subscribeOnReconnected -\nIndicates whether the client should subscribe to the channel when reconnected (if it was previously subscribed when connected).\n\n*\tfilter - Filter to apply to messages\n\n***Example:***\n\n\tRCTRealtimeMessaging.RTSubscribeWithFilter(\"MyChannel\", true, \"message.a = 1\");\n\n----------\n\n##### RTSubscribeWithOptions(options)\n\nSubscribes to a channel to receive messages sent to it with given options.\n\n**Parameters**\n\n* options - The subscription options dictionary, EX:\noptions = {\n\tchannel,\n\tsubscribeOnReconnected, // optional, default = true,\n\twithNotifications (Bool), // optional, default = false, use push notifications as in subscribeWithNotifications\n\tfilter, // optional, default = \"\", the subscription filter as in subscribeWithFilter\n\tsubscriberId // optional, default = \"\", the subscriberId as in subscribeWithBuffer\n\t}\n\n***Example:***\n\n\tvar options = {\n\t\t\t\"channel\":\"YOUR_CHANNEL_NAME\", \n\t\t\t\"subscriberId\":\"CLIENT_SUBSCRIBER_ID\", \n\t\t\t\"filter\":\"MESSAGE_FILTER\"\n\t\t\t}\n\tRCTRealtimeMessaging.RTSubscribeWithOptions(options);\n\n----------\n\n##### RTSubscribeWithBuffer(channel, subscriberId)\n\nSubscribes to a channel to receive messages published to it.\n\n**Parameters**\n\n* channel - The channel name.\n* subscriberId - The subscriberId associated to the channel.\n\n***Example:***\n\n\tRCTRealtimeMessaging.RTSubscribeWithBuffer(\"MyChannel\", \"CLIENT_SUBSCRIBER_ID\");\n\n----------\n\n##### RTSubscribeWithNotifications(channel, subscribeOnReconnect: boolean)\n\nSubscribes a pub/sub channel with Push Notifications Service, to receive messages even if the app is not running.\n\n**Parameters**\n\n* channel - Channel name\n\n* subscribeOnReconnected -\nIndicates whether the client should subscribe to the channel when reconnected (if it was previously subscribed when connected).\n\n***Example:***\n\n\tRCTRealtimeMessaging.RTSubscribeWithNotifications(\"MyChannel\", true);\n\n----------\n\n##### RTUnsubscribe(channel)\n\nUnsubscribes a channel.\n\n**Parameters**\n\n* channel - Channel name.\n\n***Example:***\n\n\tRCTRealtimeMessaging.RTUnsubscribe(\"MyChannel\");\n\n----------\n\n##### RTSendMessage(message, channel)\n\nSends a message to a pub/sub channel.\n\n**Parameters**\n\n* channel - Channel name\n\n* message - The message to send (a string/stringified JSON object)\n\n***Example:***\n\n\tRCTRealtimeMessaging.RTSendMessage(\"Hello World\",\"MyChannel\");\n\n----------\n\n##### RTPublishMessage(channel, message, ttl, onPublishResultCallback)\n\nPublish a message to a channel.\n\n**Parameters**\n\n * channel - The channel name.\n * message - The message to publish.\n * ttl - The message expiration time in seconds (0 for maximum allowed ttl).\n * onPublishResultCallback - callback returns error if message publish was not successful or published message unique id (seqId) if sucessfully published\n \n***Example:***\n\n\tRCTRealtimeMessaging.RTPublishMessage(\"MyChannel\", \"Hello World\", ttl, function(error, seqId){\n\n\t});\n\n----------\n\n##### RTEnablePresence(aPrivateKey, channel, aMetadata:boolean)\n\nEnables presence for the specified channel with first 100 unique connection metadata.\n\n**Parameters**\n\n* privateKey - The Realtime application private key\n\n* channel - Channel to enable presence\n\n* metadata - Sets to return metadata info\n\n\n***Example:***\n\n\tRCTRealtimeMessaging.RTEventListener(\"onEnablePresence\", function(event){\n\t\tif(event.result){\n\t\t\tconsole.log('Realtime enablePresence result: ' + event.result);\n\t\t}else{\n\t\t\tconsole.log('Realtime enablePresence error: ' + event.error);\n\t\t}\n\t}),\n\n\tRCTRealtimeMessaging.RTEnablePresence(aPrivateKey, channel, aMetadata);\n\n\n----------\n\n##### RTDisablePresence(aPrivateKey, channel)\n\nDisables presence for the specified channel.\n\n**Parameters**\n\n* privateKey - The Realtime application private key\n\n* channel - Channel to disable presence\n\n***Example:***\n\n\tRCTRealtimeMessaging.RTEventListener(\"onDisablePresence\", function(event){\n\t\tif(event.result){\n\t\t\tconsole.log('Realtime disablePresence result: ' + event.result);\n\t\t}else{\n\t\t\tconsole.log('Realtime disablePresence error: ' + event.error);\n\t\t}\n\t}),\n\n\tRCTRealtimeMessaging.RTDisablePresence(aPrivateKey, channel);\n\n----------\n\n##### RTPresence(channel)\n\nGets a dictionary with the total number of subscriptions in the specified channel and if active the first 100 unique connection metadata of the subscribers.\n\n**Parameters**\n\n* channel - Channel with presence data active\n\n***Example:***\n\n\tRCTRealtimeMessaging.RTEventListener(\"onPresence\", function(event){\n\t\tif(event.result){\n\t\t\tconsole.log('Realtime presence result: ' + JSON.stringify(event.result));\n\t\t}else{\n\t\t\tconsole.log('Realtime presence error: ' + event.error);\n\t\t}\n\t}),\n\n\tRCTRealtimeMessaging.RTPresence(channel);\n\n----------\n\n##### RTIsSubscribed(channel, callBack: function)\n\nIndicates whether a given channel is currently subscribed.\n\n**Parameters**\n\n* channel - Channel name.\n\n* callback - Callback function to be called with the result (true or false).\n\n***Example:***\n\n\tRCTRealtimeMessaging.RTIsSubscribed(\"MyChannel\", function(result){\n\t\tif(result == true){\n\t\t\tconsole.log('channel is subscribed');\n\t\t}else{\n\t\t\tconsole.log('channel is not subscribed');\n\t\t}\n\t});\n\n----------\n\n##### RTGetHeartbeatTime(callBack: function)\n\nGet the client heartbeat interval.\n\n**Parameters**\n\n* callback -\nCallback function with the heartbeat interval value\n\n***Example:***\n\n\tRCTRealtimeMessaging.RTGetHeartbeatTime(function(result){\n\t\tconsole.log('HeartbeatTime for this client is: ' + result);\n\t});\n\n----------\n\n##### RTSetHeartbeatTime(newHeartbeatTime)\n\nSets the client heartbeat interval.\n\n**Parameters**\n\n* newHeartbeatTime - The new heartbeat interval\n\n***Example:***\n\n\tRCTRealtimeMessaging.RTSetHeartbeatTime(10);\n\n----------\n\n##### RTGetHeartbeatFails(callBack: function)\n\nNumber of times the heartbeat can fail before the connection is reconnected\n\n**Parameters**\n\n* callBack - The callback function to get the HeartbeatFails value\n\n***Example:***\n\n\tRCTRealtimeMessaging.RTGetHeartbeatFails(function(result){\n\t\tconsole.log('HeartbeatFails Time for this client is: ' + result);\n\t});\n\n----------\n\n##### RTSetHeartbeatFails(newHeartbeatFails)\n\nSets the number of times the heartbeat can fail before the connection is reconnected\n\n**Parameters**\n\n* newHeartbeatFails - The new heartbeat fails value\n\n***Example:***\n\n\tRCTRealtimeMessaging.RTSetHeartbeatFails(3);\n\n----------\n\n##### RTIsHeartbeatActive(callBack: function)\n\nIndicates whether the client heartbeat is active or not.\n\n**Parameters**\n\n* callBack - The callback function with the result\n\n***Example:***\n\n\tRCTRealtimeMessaging.RTIsHeartbeatActive(function(result){\n\t\tif(result == true){\n\t\t\tconsole.log('heartbeat active');\n\t\t}else{\n\t\t\tconsole.log('heartbeat inactive');\n\t\t}\t\t\n\t});\n\n----------\n\n##### RTEnableHeartbeat()\n\nEnables the client heartbeat.\n\n***Example:***\n\n\tRCTRealtimeMessaging.RTEnableHeartbeat()\n\n----------\n\n##### RTDisableHeartbeat()\n\nDisables the client heartbeat.\n\n***Example:***\n\n\tRCTRealtimeMessaging.RTDisableHeartbeat()\n\n\n\n## Full example ( index.android.js )\n\n\t'use strict';\n\n\timport React, { Component } from 'react';\n\timport realtime from './RCTRealtimeMessagingAndroid';\n\tvar RCTRealtimeMessaging = new realtime();\n\n\tvar messages = [];\n\n\timport {\n\t  AppRegistry,\n\t  Image,\n\t  StyleSheet,\n\t  Text,\n\t  Navigator,\n\t  TextInput,\n\t  ScrollView,\n\t  TouchableHighlight,\n\t  ListView,\n\t  View\n\t} from 'react-native';\n\n\n\tvar RealtimeRCT = React.createClass({\n\n\t  doConnect: function(){\n\t    this._log('Trying to connect!');\n\n\t    RCTRealtimeMessaging.RTEventListener(\"onConnected\",this._onConnected),\n\t    RCTRealtimeMessaging.RTEventListener(\"onDisconnected\",this._onDisconnected),\n\t    RCTRealtimeMessaging.RTEventListener(\"onSubscribed\",this._onSubscribed),\n\t    RCTRealtimeMessaging.RTEventListener(\"onUnSubscribed\",this._onUnSubscribed),\n\t    RCTRealtimeMessaging.RTEventListener(\"onException\",this._onException),\n\t    RCTRealtimeMessaging.RTEventListener(\"onMessage\",this._onMessage),\n\t    RCTRealtimeMessaging.RTEventListener(\"onPresence\",this._onPresence);\n\n\t    RCTRealtimeMessaging.RTConnect(\n\t    {\n\t      appKey:this.state.appKey,\n\t      token:this.state.token,\n\t      connectionMetadata:this.state.connectionMetadata,\n\t      clusterUrl:this.state.clusterUrl,\n\t      projectId:'\u003cYOUR_GOOGLE_PROJECT_NUMBER\u003e'\n\t    });\n\t  },\n\n\t  componentDidMount: function(){\n\t\t  RCTRealtimeMessaging.RTPushNotificationListener(this._onNotification);\n\t  },\n\n\t  _onNotification: function(data) {\n\t\t this._log(\"Received push notification: \" + JSON.stringify(data));  \n\t  },\n\n\t  componentWillUnmount: function() {\n\t    RCTRealtimeMessaging.RTDisconnect();\n\t  },\n\n\t  doDisconnect:function(){\n\t      RCTRealtimeMessaging.RTDisconnect();\n\t  },\n\n\t  doSubscribe: function(){\n\t    RCTRealtimeMessaging.RTSubscribe(this.state.channel, true);\n\t    // To subscribe using push notifications use the RTSubscribeWithNotifications method\n\t  },\n\n\t  doUnSubscribe: function(){\n\t    RCTRealtimeMessaging.RTUnsubscribe(this.state.channel);\n\t  },\n\n\t  doSendMessage: function(){\n\t    RCTRealtimeMessaging.RTSendMessage(this.state.message, this.state.channel);\n\t  },\n\n\t  doPresence: function(){\n\t    RCTRealtimeMessaging.RTPresence(\n\t       this.state.channel\n\t     );\n\t  },\n\n\n\t  _onException: function(exceptionEvent){\n\t    this._log(\"Exception:\" + exceptionEvent.error);\n\t  },\n\n\t  _onConnected: function()\n\t  {\n\t    this._log(\"connected\");\n\t  },\n\n\n\t  _onDisconnected: function(){\n\t    this._log(\"disconnected\");\n\t  },\n\n\t  _onSubscribed: function(subscribedEvent)\n\t  {\n\t    this._log(\"subscribed channel \" + subscribedEvent.channel);\n\t  },\n\n\t  _onUnSubscribed: function(unSubscribedEvent)\n\t  {\n\t    this._log(\"unsubscribed channel \" + unSubscribedEvent.channel);\n\t  },\n\n\t  _onMessage: function(messageEvent)\n\t  {\n\t    this._log(\"received message: [\"+messageEvent.message+\"] on channel [\" + messageEvent.channel+\"]\");  \n\t  },\n\n\t  _onPresence: function(presenceEvent){\n\t    if (presenceEvent.error) {\n\t      this._log(\"Error getting presence: \" + presenceEvent.error);\n\t    }else\n\t    {\n\t      this._log(\"Presence data: \" + JSON.stringify(presenceEvent.result));\n\t    };    \n\t  },\n\n\n\t  getInitialState: function() {\n\t    return {\n\t      clusterUrl: \"http://ortc-developers.realtime.co/server/2.1/\",\n\t      token: \"SomeAuthenticatedToken\",\n\t      appKey: \"YOUR_APP_KEY\",\n\t      channel: \"yellow\",\n\t      connectionMetadata: \"clientConnMeta\",\n\t      message: \"some message\",\n\t      dataSource: new ListView.DataSource({\n\t        rowHasChanged: (row1, row2) =\u003e row1 !== row2,\n\t      }),\n\t    };\n\t  },\n\n\t  _renderRow: function(rowData: string, sectionID: number, rowID: number) {\n\t    return (\n\t      \u003cTouchableHighlight\u003e\n\t        \u003cView\u003e\n\t          \u003cView style={styles.row}\u003e\n\t            \u003cText style={styles.text}\u003e\n\t              {rowData}\n\t            \u003c/Text\u003e\n\t          \u003c/View\u003e\n\t          \u003cView style={styles.separator} /\u003e\n\t        \u003c/View\u003e\n\t      \u003c/TouchableHighlight\u003e\n\t    );\n\t  },\n\n\t  _log: function(message: string)\n\t  {\n\t    var time = this.getFormattedDate();\n\t    time += \" - \" + message\n\t    var temp = [];\n\t    temp[0] = time;\n\n\t    for (var i = 0; i \u003c messages.length; i++) {\n\t      temp[i+1] =  messages[i];\n\t    };\n\t    messages = temp;\n\n\t    this.setState({\n\t      dataSource: this.getDataSource(messages)\n\t    });\n\t  },\n\n\t  getFormattedDate: function() {\n\t    var date = new Date();\n\t    var str = date.getHours() + \":\" + date.getMinutes() + \":\" + date.getSeconds();\n\t    return str;\n\t  },\n\n\t  getDataSource: function(messages: Array\u003cany\u003e): ListView.DataSource {\n\t    return this.state.dataSource.cloneWithRows(messages);\n\t  },\n\n\t  render: function() {\n\t    return (\n\t      \u003cScrollView style={styles.container}\u003e\n\n\t        \u003cText clusterUrl = {this.state.clusterUrl} \u003e\n\t            clusterUrl:\n\t        \u003c/Text\u003e\n\t        \u003cTextInput\n\t          style={styles.textInput}\n\t          placeholder={this.state.clusterUrl}\n\t          onChangeText={(text) =\u003e this.setState({server: text})}\n\t        /\u003e\n\n\t        \u003cView style={styles.custom}\u003e\n\t          \u003cView style={styles.margin}\u003e\n\t            \u003cText server = {this.state.server} \u003e\n\t                Authentication Token:\n\t            \u003c/Text\u003e\n\t            \u003cTextInput\n\t              style={styles.halfTextInput}\n\t              placeholder={this.state.token}\n\t              onChangeText={(text) =\u003e this.setState({token: text})}\n\t            /\u003e\n\n\t            \u003cText server = {this.state.server} \u003e\n\t                Application Key:\n\t            \u003c/Text\u003e\n\t            \u003cTextInput\n\t              style={styles.halfTextInput}\n\t              placeholder={this.state.appKey}\n\t              onChangeText={(text) =\u003e this.setState({appKey: text})}\n\t            /\u003e\n\t          \u003c/View\u003e\n\n\t          \u003cView style={styles.margin}\u003e\n\t            \u003cText server = {this.state.server} \u003e\n\t                Channel:\n\t            \u003c/Text\u003e\n\t            \u003cTextInput\n\t              style={styles.halfTextInput}\n\t              placeholder={this.state.channel}\n\t              onChangeText={(text) =\u003e this.setState({channel: text})}\n\t            /\u003e\n\n\t            \u003cText server = {this.state.server} \u003e\n\t                Connection Metadata:\n\t            \u003c/Text\u003e\n\t            \u003cTextInput\n\t              style={styles.halfTextInput}\n\t              placeholder={this.state.connectionMetadata}\n\t              onChangeText={(text) =\u003e this.setState({connectionMetadata: text})}\n\t            /\u003e\n\t          \u003c/View\u003e\n\n\t        \u003c/View\u003e\n\t        \u003cText server = {this.state.server} \u003e\n\t            Message:\n\t        \u003c/Text\u003e\n\t        \u003cTextInput\n\t          style={styles.textInput}\n\t          placeholder={this.state.message}\n\t          onChangeText={(text) =\u003e this.setState({message: text})}\n\t        /\u003e\n\n\n\t        \u003cView style={styles.rowView}\u003e\n\n\t          \u003cTouchableHighlight style={styles.button} onPress={this.doConnect}\u003e\n\t            \u003cView style={styles.tryAgain}\u003e\n\t              \u003cText style={styles.tryAgainText}\u003eConnect\u003c/Text\u003e\n\t            \u003c/View\u003e\n\t          \u003c/TouchableHighlight\u003e\n\n\t          \u003cTouchableHighlight style={styles.button} onPress={this.doDisconnect}\u003e\n\t            \u003cView style={styles.tryAgain}\u003e\n\t              \u003cText style={styles.tryAgainText}\u003eDisconnect\u003c/Text\u003e\n\t            \u003c/View\u003e\n\t          \u003c/TouchableHighlight\u003e\n\n\t          \u003cTouchableHighlight style={styles.button} onPress={this.doSubscribe}\u003e\n\t            \u003cView style={styles.tryAgain}\u003e\n\t              \u003cText style={styles.tryAgainText}\u003eSubscribe\u003c/Text\u003e\n\t            \u003c/View\u003e\n\t          \u003c/TouchableHighlight\u003e\n\n\t          \u003cTouchableHighlight style={styles.button} onPress={this.doUnSubscribe}\u003e\n\t            \u003cView style={styles.tryAgain}\u003e\n\t              \u003cText style={styles.tryAgainText}\u003eUnsubscribe\u003c/Text\u003e\n\t            \u003c/View\u003e\n\t          \u003c/TouchableHighlight\u003e\n\n\t          \u003cTouchableHighlight style={styles.button} onPress={this.doSendMessage}\u003e\n\t            \u003cView style={styles.tryAgain}\u003e\n\t              \u003cText style={styles.tryAgainText}\u003eSend\u003c/Text\u003e\n\t            \u003c/View\u003e\n\t          \u003c/TouchableHighlight\u003e\n\n\t          \u003cTouchableHighlight style={styles.button} onPress={this.doPresence}\u003e\n\t            \u003cView style={styles.tryAgain}\u003e\n\t              \u003cText style={styles.tryAgainText}\u003ePresence\u003c/Text\u003e\n\t            \u003c/View\u003e\n\t          \u003c/TouchableHighlight\u003e\n\n\t        \u003c/View\u003e\n\t        \u003cListView\n\t          style={styles.list}\n\t          dataSource={this.state.dataSource}\n\t          renderRow={this._renderRow}\n\t        /\u003e\n\t      \u003c/ScrollView\u003e\n\n\t    )}\n\t  });\n\n\tvar styles = StyleSheet.create({\n\t  container: {\n\t    marginTop: 30,\n\t    margin: 5,\n\t    backgroundColor: '#FFFFFF',\n\t  },\n\t  list: {\n\t    flexDirection: 'column',\n\t    backgroundColor: '#F6F6F6',\n\t    height:150,\n\t  },\n\t  rowView:{\n\t    alignItems: 'stretch',\n\t    flexDirection: 'row',\n\t    flexWrap: 'wrap',\n\t    justifyContent:'center',\n\t  },\n\t  button:{\n\t    margin: 5,\n\t  },\n\t  margin:{\n\n\t  },\n\t  custom:{\n\t    flexDirection: 'row',\n\t    flexWrap: 'wrap',\n\t    justifyContent:'space-between',\n\t  },\n\t  textInput:{\n\t    height: 30,\n\t    borderColor: 'gray',\n\t    borderWidth: 1,\n\t    borderRadius: 4,\n\t    padding: 5,\n\t    fontSize: 15,\n\t  },\n\n\t  halfTextInput:{\n\t    height: 30,\n\t    borderColor: 'gray',\n\t    borderWidth: 1,\n\t    borderRadius: 4,\n\t    padding: 5,\n\t    fontSize: 15,\n\t    width: 153,\n\t  },\n\t  tryAgain: {\n\t    backgroundColor: '#336699',\n\t    padding: 13,\n\t    borderRadius: 5,\n\t  },\n\t  tryAgainText: {\n\t    color: '#ffffff',\n\t    fontSize: 14,\n\t    fontWeight: '500',\n\t  },\n\t  welcome: {\n\t    fontSize: 20,\n\t    textAlign: 'center',\n\t    margin: 10,\n\t  },\n\t  instructions: {\n\t    textAlign: 'center',\n\t    color: '#333333',\n\t  },\n\t  row: {\n\t    flexDirection: 'row',\n\t    justifyContent: 'center',\n\t    padding: 10,\n\t    backgroundColor: '#F6F6F6',\n\t  },\n\t  separator: {\n\t    height: 1,\n\t    backgroundColor: '#CCCCCC',\n\t  },\n\t  thumb: {\n\t    width: 64,\n\t    height: 64,\n\t  },\n\t  text: {\n\t    flex: 1,\n\t    fontSize: 13,\n\t  },\n\t});\n\n\tAppRegistry.registerComponent('RealtimeRCT', () =\u003e RealtimeRCT);\n\n## Example\nCheckout the example at [https://github.com/realtime-framework/RealtimeMessaging-ReactNativeAndroidExample](https://github.com/realtime-framework/RealtimeMessaging-ReactNativeAndroidExample)\n## Authors\nRealtime.co\n","funding_links":[],"categories":["Components"],"sub_categories":["Integrations"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealtime-framework%2FRCTRealtimeMessagingAndroid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frealtime-framework%2FRCTRealtimeMessagingAndroid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealtime-framework%2FRCTRealtimeMessagingAndroid/lists"}