Plugin Directory

Changeset 2781465


Ignore:
Timestamp:
09/07/2022 03:35:28 PM (4 years ago)
Author:
tapchat
Message:

Version 1.0.3

Location:
tapchat
Files:
37 added
4 edited

Legend:

Unmodified
Added
Removed
  • tapchat/trunk/includes/class-tapchat-api.php

    r2778404 r2781465  
    345345
    346346    function savePushToken($request){
    347 
    348         $pushToken = $request['pushToken'];
    349         $playerId = $request['userId'];
    350         $deviceSerial = $request['deviceSerial'];
    351        
    352         if($request['wpUserID']){
    353 
    354             $wpUserID = $request['wpUserID'];
    355 
    356 
    357             $playerIds = get_user_meta($wpUserID, 'os_playerid', true);
    358             $deviceIds = get_user_meta($wpUserID, 'device_id', true);
    359             $pushtoken = get_user_meta($wpUserID, 'os_pushtoken', true);
    360 
    361             $pushNotificationData = array();
    362             $savePlayerIds = array();
    363             if(!is_array($playerIds)){
    364                 if(!empty($playerIds)){
    365                     $pushNotificationData[] = array('deviceId'=>$deviceIds,'playerId'=>$playerIds,'pushtoken'=>$pushtoken);
    366                     $savePlayerIds[] = $playerIds;
    367                 }
    368             }
    369             $pushNotificationData[] = array('deviceId'=>$deviceSerial,'playerId'=>$playerId,'pushtoken'=>$pushToken);
    370             $savePlayerIds[] = $playerId;
    371 
    372             update_user_meta($wpUserID, 'os_playerid', $savePlayerIds);
    373             update_user_meta($wpUserID, 'os_push_notification_data', $pushNotificationData);
    374 
    375             wp_send_json(array("status"=>'onsignal-saved','message'=>'Onesignal token data saved to wordpress.'));
    376 
     347        $response = array('code'=>"auth_error",'message'=>"Fail to authanticate.");
     348        if(empty($_SERVER['HTTP_TC_ACCESS_TOKEN'])){
     349            wp_send_json($response);
     350            exit;
     351        }
     352       
     353        $this->get_tapchat_admin($request);
     354        if(!$this->userId){
     355            wp_send_json(array('code'=>'invalid_request','message'=>"Invalid Operator Request!"));
     356            exit;
     357        }
     358
     359        $deviceSerial = $request['deviceToken'];
     360       
     361        if(!empty($deviceSerial)){
     362            update_user_meta($this->userId,'_tap_chat_oprator_token',$deviceSerial);
     363            $response = array('message'=>"Token saved.");
    377364        }else{
    378 
    379             wp_send_json(array("status"=>'user-missing','message'=>'Wordpress user not found.'));
    380 
    381         }
     365            $response = array('code'=>"missing_param",'message'=>"Required Parameter missing.");
     366        }
     367        wp_send_json($response);
    382368        exit;
    383369    }
  • tapchat/trunk/includes/class-tapchat.php

    r2736956 r2781465  
    132132                if($send_notification){
    133133                    // push Notification
     134                    $device_token = get_user_meta($operator_id,'_tap_chat_oprator_token',true);
     135                    if($device_token){
     136                        $api_id = $this->options['api_key'];
     137                        $args = array(
     138                            'headers' => array('Accept' => 'application/vnd.hmrc.1.0+json',
     139                                                'Authorization' => 'Bearer '.$api_id
     140                            ),
     141                            'body'        => array(
     142                                'token' => $device_token,
     143                            ),
     144                        );
     145                        $resp = wp_remote_post( 'https://dashboard.tapchat.me/api/call/send-push-notification', $args );
     146   
     147                        $data = json_decode(wp_remote_retrieve_body($resp));
     148
     149                        $response["notification_status"] = $data;
     150                       
     151                    }
    134152                }
    135153            }
  • tapchat/trunk/readme.txt

    r2778564 r2781465  
    55Tested up to: 6.0.2
    66Requires PHP: 7.2
    7 Stable tag: 1.0.2
     7Stable tag: 1.0.3
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    5353== Changelog ==
    5454= 1.0.2 =
     55* update Mobile push notification
     56= 1.0.2 =
    5557* update Mobile API
    5658= 1.0.1 =
  • tapchat/trunk/tapchat.php

    r2778404 r2781465  
    44* Plugin URI: https://tapchat.me/
    55* Description: This pluin provide an integration between tapchat Mobile App
    6 * Version: 1.0.2
    7 * Stable tag: 1.0.2
     6* Version: 1.0.3
     7* Stable tag: 1.0.3
    88* Author: Phillip Dane
    99* Author URI: https://www.linkedin.com/in/phillipdane/
Note: See TracChangeset for help on using the changeset viewer.