Php 世博推送通知发送到多个设备,而不是一个设备

Php 世博推送通知发送到多个设备,而不是一个设备,php,push-notification,expo,push,react-native-push-notification,Php,Push Notification,Expo,Push,React Native Push Notification,我正在使用expo管理的工作流开发移动应用程序。我的应用程序后端有PHP REST API。 我在处理应用程序的推送通知部分时遇到了一个奇怪的问题 我正在使用两种不同的设备进行测试,一部iPhone和一部Android手机。两台设备都使用不同的用户帐户登录应用程序,并且两台设备都在db中设置了不同的expo push通知令牌 当管理员希望向特定用户发送新的报价时,推送通知将由两个设备接收,而不是仅由属于管理员希望向其发送消息的用户的设备接收 下面是我如何从后端发送通知。这段代码只执行一次,所以我

我正在使用expo管理的工作流开发移动应用程序。我的应用程序后端有PHP REST API。 我在处理应用程序的推送通知部分时遇到了一个奇怪的问题

我正在使用两种不同的设备进行测试,一部iPhone和一部Android手机。两台设备都使用不同的用户帐户登录应用程序,并且两台设备都在db中设置了不同的expo push通知令牌

当管理员希望向特定用户发送新的报价时,推送通知将由两个设备接收,而不是仅由属于管理员希望向其发送消息的用户的设备接收

下面是我如何从后端发送通知。这段代码只执行一次,所以我想我在这里做错了什么

$this->expo = Expo::normalSetup();
$interest = 'new_offer';

// Subscribe the recipient to the server
$this->expo->subscribe($interest, $recipient);

// Build the notification data
$notification = [
   'title' => $this->title,
   'body' => $body,
   'data' => json_encode([
      'type' => $this->type,
      'inquiryId' => $this->inquiry->getId(),
      'offerId' => $this->offer->getId(),
      ]),
   ];

// Notify an interest with a notification
$this->expo->notify($interest, $notification);
下面是我在应用程序中如何处理它

    /**
     * Get Expo push token and connect it with the user
     * @see https://docs.expo.io/versions/latest/guides/push-notifications/
     * @returns {Promise<void>}
     */
    registerForPushNotificationsAsync = async () => {
        const {status: existingStatus} = await Permissions.getAsync(Permissions.NOTIFICATIONS);
        let finalStatus = existingStatus;

        // only ask if permissions have not already been determined, because
        // iOS won't necessarily prompt the user a second time.
        if (existingStatus !== 'granted') {
            // Android remote notification permissions are granted during the app
            // install, so this will only ask on iOS
            const {status} = await Permissions.askAsync(Permissions.NOTIFICATIONS);
            finalStatus = status;
        }

        // Stop here if the user did not grant permissions
        if (finalStatus !== 'granted') {
            return;
        }

        // Get the token that uniquely identifies this device
        const token = await Notifications.getExpoPushTokenAsync();

        /**
         * @token ExponentPushToken[cszdf-SKFcXkd-8e6BEtjNG]
         */

        this.pushNotificationsToken = token;
        this._notificationSubscription = Notifications.addListener(this._handleNotification);
    }

    _handleNotification = ({origin, data}) => {
        console.warn(origin, data);

        switch (data.type) {
            case PushNotificationTypes.PARTNER_SUBMITTED_NEW_OFFER: {
                return this.props.navigation.navigate('InquiryOffers', {getInquiryId: data.inquiryId});
            }
        }
    }
/**
*获取Expo推送令牌并将其与用户连接
*@见https://docs.expo.io/versions/latest/guides/push-notifications/
*@returns{Promise}
*/
registerForPushNotificationsAsync=async()=>{
const{status:existingStatus}=wait Permissions.getAsync(Permissions.NOTIFICATIONS);
设finalStatus=existingStatus;
//仅询问权限是否尚未确定,因为
//iOS不一定会再次提示用户。
如果(existingStatus!=“已授予”){
//Android远程通知权限是在应用程序运行期间授予的
//安装,因此这将仅在iOS上询问
const{status}=wait Permissions.askAsync(Permissions.NOTIFICATIONS);
最终状态=状态;
}
//如果用户未授予权限,请停止此处
如果(最终状态!==‘已授予’){
返回;
}
//获取唯一标识此设备的令牌
const token=等待通知。getExpoPushTokenAsync();
/**
*@token ExponentPushToken[cszdf-SKFcXkd-8e6BEtjNG]
*/
this.pushNotificationsToken=令牌;
this.\u notificationSubscription=Notifications.addListener(this.\u handleNotification);
}
_handleNotification=({来源,数据})=>{
控制台。警告(来源、数据);
开关(数据类型){
案例推送通知类型。合作伙伴提交的新报价:{
返回this.props.navigation.navigate('InquiryOffers',{getInquiryId:data.inquiryId});
}
}
}
你知道我做错了什么以及如何修复吗

谢谢

鲍勃