HQ Demo App, built using PubNub Functions to create realtime live game show experience for players. For full tutorial, click here
Admin App | Client App |
---|---|
Sign up for PubNub click here:
PubNub Functions Setup
- Create a new Project.
- Go to Key Info and enable Presence, PubNub Functions, and Access Manager.
- Create Functions module and within it create 3 functions: getAnswers, submitAnswer, and grantAccess.
- Enter code for each function into its respective code editor on PubNub functions page.
- Ensure that PubNub Functions module is started and running.
Android App Setup
-
Go to Key Info and take note of your subscribe key and publish key. You will need to go to the Constants.java class and enter these credentials where it says INSERT_SUBSCRIBE_KEY and INSERT_PUBLISH_KEY respectively. Enter grantAccess PubNub function URL in Constants.java class.
-
Ensure that you have the following gradle dependencies:
Module Build.gradle
implementation 'com.android.volley:volley:1.1.0'
implementation group: 'com.pubnub', name: 'pubnub-gson', version: '4.12.0'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
Project Build.gradle
repositories {
maven { url 'https://jitpack.io' }
google()
jcenter()
}
- Ensure that you have the following Android Manifest Permissions:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Javascript Web App setup
-
Enter getAnswers PubNub Functions URL into code, where it says ENTER_GET_ANSWERS_PFUNC_URL on the top of index.js file.
-
Enter Subscribe Key, Publish Key, and Secret Key at the top of the index.js file also.
Congrats! You have successfully set up HQ Demo App and it is ready to run.