0

我正在使用firebase功能一段時間,但我堅持一步,那一步是當我想發送/推阿拉伯文本設備接收此文本爲不可讀文本,我couldn 「T解決這個問題到現在爲止,所以是有這個問題的任何修復,這裏是我的代碼,我在函數中使用:Firebase函數不能推阿拉伯文本

'use strict' 
 

 
const functions = require('firebase-functions'); 
 
const admin = require('firebase-admin'); 
 
admin.initializeApp(functions.config().firebase); 
 

 
exports.n_likes_en = functions.database.ref('/notifications/{user_id}/{notification_id}').onWrite(event =>{ 
 

 
    const user_id = event.params.user_id; 
 
    const notification_id = event.params.notification_id; 
 
     
 
    const language = admin.database().ref(`/users/${user_id}/lang`).once('value'); 
 
    
 
    return language.then(LanguageResult =>{ 
 
     
 
     const Lang_Val = LanguageResult.val(); 
 
     
 
     if (Lang_Val == "ar"){ 
 
     
 
      const fromUser = admin.database().ref(`/notifications/${user_id}/${notification_id}`).once('value'); 
 

 
      return fromUser.then(fromUserResult =>{ 
 
     
 
       const from_user_id = fromUserResult.val().uid; 
 
     
 
       const user_like = fromUserResult.val().describe; 
 
     
 
       if (user_like == "l"){ 
 
      
 
        const userQuery = admin.database().ref(`/users/${from_user_id}/username`).once('value');   
 
      
 
        return userQuery.then(userResult => { 
 
       
 
         const username = userResult.val(); 
 
      
 
         const device_token = admin.database().ref(`/users/${user_id}/id`).once('value'); 
 
       
 
         return device_token.then(result =>{ 
 

 
          const token_id = result.val(); 
 

 
          const payload = { 
 
           
 
           notification:{ 
 
            
 
            title : "Rankzone", 
 
          
 
            body : `${username}’ + أعجب بمنشورك` 
 
            
 
            icon : "default"}}; 
 

 
          return admin.messaging().sendToDevice(token_id, payload).then(response); 
 
         }); 
 
        }); 
 
       }}); 
 
     }}); 
 
});

的問題是通知的正文它不能在我的設備中收到通知時可以讀取。

請幫助任何人。

回答

0

我已經解決了我的問題,通過從數據庫中檢索您需要的阿拉伯語翻譯或任何語言,並將它放在通知的正文中。