将印地语的 gcm 通知发送到 android 应用程序

send gcm notification in hindi language to android app

我是 android.I 的新手,想用印地语发送 gcm 通知。每当我用英语发送通知时,一切正常,但是当我用印地语发送通知时,android 应用程序会收到以下输出 नमस्ते 我不知道为什么我会收到这个 output.Please 帮助我解决我的错误。

下面是我的php代码

<?php

    //Checking http request we are using post here

        //Getting api key
        $api_key = "API key here";
        require'connect_to_db.php';
        $query="SELECT gcm_token FROM users";


         if($row=mysqli_query($con,$query)){
            $reg_token = array();
            while($query_row = mysqli_fetch_assoc($row)) {

                array_push($reg_token, $query_row['gcm_token']);

            }
         }





    //Getting the message
    $message = $_POST['message'];
    $title = $_POST['title'];
    $url = $_POST['url'];

    //Creating a message array
    $msg = array
    (
        'message'   => $message,
        'title'     => $title,
        'url'   => $url,
        'tickerText'    => 'Ticker text here...Ticker text here...Ticker text here',
        'vibrate'   => 1,
        'sound'     => 1,
        'largeIcon' => 'large_icon',
        'smallIcon' => 'small_icon'
    );

    //Creating a new array fileds and adding the msg array and registration token array here
    $fields = array
    (
        'registration_ids'  => $reg_token,
        'data'          => $msg,
        'priority'  =>'high'
    );

    //Adding the api key in one more array header
    $headers = array
    (
        'Authorization: key=' . $api_key,
        'Content-Type: application/json'
    );

    //Using curl to perform http request
    $ch = curl_init();
    curl_setopt( $ch,CURLOPT_URL, 'https://android.googleapis.com/gcm/send' );
    curl_setopt( $ch,CURLOPT_POST, true );
    curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
    curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
    curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
    curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );

    //Getting the result
    $result = curl_exec($ch );
    curl_close( $ch );

    //Decoding json from result
    $res = json_decode($result);


    //Getting value from success
    $flag = $res->success;

    //if success is 1 means message is sent
    if($flag == 1){
        echo $result;
    }else{

        echo $result;
    }

    mysqli_close($con);
?>

我整理出 ​​problem.The 背后的原因是 android 应用程序正在接收 unicode 字符,因此我需要对其进行解码.. 我简单地使用这个功能 Html.fromHtml(留言); 正在将文本转换为印地语