Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var app = {
- initialize: function() {
- this.bindEvents();
- },
- bindEvents: function() {
- document.addEventListener('deviceready', this.onDeviceReady, false);
- },
- onDeviceReady: function() {
- var push = PushNotification.init({
- "android": {
- "senderID": "xxxxxxxxx"
- },
- "ios": {"alert": "true", "badge": "true", "sound": "true"},
- "windows": {}
- });
- push.on('registration', function(data) {
- console.log("registration event");
- var gcm_regid = data.registrationId;
- $.post('http://xxxxx.xxx/insert.php', {gcm_regid: gcm_regid});
- return false;
- });
- <?php
- $con = mysql_connect("localhost","gcm","password");
- if (!$con) {
- die('Could not connect: ' . mysql_error());
- }
- mysql_select_db("gcm", $con);
- $gcm_regid=$_POST['gcm_regid'];
- $query=mysql_query("INSERT INTO gcm_users(gcm_regid) VALUES('$gcm_regid')");
- if($query){
- echo "Data for $gcm_regid inserted successfully!";
- }
- else{ echo "An error occurred!"; }
- ?>
- id -> int(11) --> AUTO_INCREMENT
- gcm_regid text
- created_at --> timestamp -> CURRENT_TIMESTAMP
- ALTER IGNORE TABLE gcm_users
- ADD UNIQUE INDEX idx_name (gcm_regid);
Add Comment
Please, Sign In to add comment