簡體   English   中英

用戶沒有收到我發來的推送通知

[英]Users Not Receiving Push Notifications Just From Me

我有一個消息應用程序,我使用 Parse 服務器作為我的后端。

推送通知在我的用戶之間工作得很好,但是每當我從我的用戶帳戶發送消息時,收件人都不會收到推送通知(即使它看起來已經很好地傳遞給 APNS)。 如果我在手機上使用其他用戶帳戶登錄,推送通知可以正常發送,但是一旦我重新登錄自己的帳戶,其他人就收不到推送通知。

我的代碼對我的用戶和其他人沒有做任何不同的事情。 消息保存到數據庫中就好了(收件人可以手動刷新以在他們的應用程序上獲取我的消息 - 他們只是沒有收到推送通知)。

似乎出於某種原因,APNS 並沒有為我的用戶提供推送通知。

有沒有人經歷過這樣的事情? 或者我有什么想法可以調試這個?

更新:發送推送的雲函數

Parse.Cloud.define("sendPushToUser2", function(request, response) {
    var senderUser = request.user;
    var recipientUserId = request.params.recipientId;
    var message = request.params.message;
    
    if (message.length > 140) {
        message = message.substring(0, 137) + "...";
    }
    
    // Find devices associated with the recipient user
    var recipientUser = new Parse.User();
    recipientUser.id = recipientUserId;
    var pushQuery = new Parse.Query(Parse.Installation);
    pushQuery.equalTo("user", recipientUser);
    
    // Send the push notification to results of the query
    Parse.Push.send({
        where: pushQuery,
        data: {
            alert: senderUser.get("name"),
            badge: "Increment",
            message: message,
            title: senderUser.get("name"),
            senderObjId: senderUser,
            sound: "sounds.caf",
            "content-available": 1
        }
    }, { success: function() {
        console.log("PUSH SUCCESSFUL");
    }, error: function(error) {
        console.log("PUSH ERROR" + error.message);
    }, useMasterKey: true});
});

我的問題是我傳入數據的這個對象“ senderObjId:senderUser ”非常大。 它可能超出了有效載荷限制。 我真的只需要那個對象中的 3 個項目,而是通過了這些項目,然后它就開始工作了。 隨着時間的推移,那個對象在我沒有注意到的情況下不斷增加,它只影響在那個對象中建立了很多東西的用戶。

感謝您對此@DaviMacêdo 的幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM