mardi 26 février 2019

How to get rid of this error(array_key_exists() expects parameter 2 to be array, null given) in laravel

I use the libraray Edujugon\PushNotification for push Notification but it give me the error.

array_key_exists() expects parameter 2 to be array, null given

Please help me Here is my code. I do not know where i make a mistake. thanks in advance

public function likeActivity(Activity $activity)
{
    $authUser = JWTAuth::parseToken()->toUser();

    $authUser->likeActivity($activity);

    if ($activity->user_id != $authUser->id) {
        $user = User::where('id', $activity->user_id)->first();

        $push = new PushNotification('apn');
        $push->setMessage([
            'aps' => [
                'alert' => $authUser->name.' like your "'.$activity->activity_type.'"'.$activity->activity_title,
                'sound' => 'default',
                'badge' =>  $user->unreadNotifications->count()

            ],
            'extraPayLoad' => [
                // 'user' => $authUser,
                // 'post' => $post->id,
                'notification_type' => "Like Your Activity",
            ]
        ]);
        $push->setDevicesToken($user->deviceToken);
        $push->send();
        $feedback = $push->getFeedback();

        $user->notify(new LikedTheActivity($authUser, $activity));
    }

    return response()->json(['user'=> $authUser], 200);
} 



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2NsemYe
via IFTTT

Aucun commentaire:

Enregistrer un commentaire