brozot / Laravel-FCM

Laravel-FCM is an easy to use package working with both Laravel and Lumen for sending push notification with Firebase Cloud Messaging (FCM).
MIT License
889 stars 409 forks source link

Trouble with additional parameters #66

Open yaroslavsnisarua opened 7 years ago

yaroslavsnisarua commented 7 years ago

Hello! First of all, thank you very much for great lib! Im using it on laravel 5.1) In testing i have a same problem.


        $optionBuilder = new OptionsBuilder();
        $optionBuilder->setTimeToLive(30);

        $notificationBuilder = new PayloadNotificationBuilder('Auth');
        $notificationBuilder->setBody('Auth request...')
            ->setSound('default');

        $dataBuilder = new PayloadDataBuilder();
        $dataBuilder->addData(['a_data'=>[
            'mode'=>'auth',
            'private_key'=>'12345678901234567890123456789012'
        ]
]);

        $option = $optionBuilder->build();
        $notification = $notificationBuilder->build();
        $data = $dataBuilder->build();

        $token = '...';

        $downstreamResponse = FCM::sendTo($token, $option, $notification, $data);

and on Android i receive:

{a_data={“mode”:“auth”,“private_key”:“MXaFORX1dKZpXMCaiLl5uNo74yOqOTJW”}}

thats Ok! I can use a_data as json/object...

BUT on iOS i have a problem!

Push notification received: {
    “a_data” = “{\“mode\“:\“auth\“,\“private_key\“:\“TpbgLUn1Zq6WwREJxy3yGvgjEeaun75z\“}”;
    aps =     {
        alert =         {
            body = “Auth request...“;
            title = Auth;
        };
        sound = default;
    };
    “gcm.message_id” = “0:1496937050152314%939d13c6939d13c6";
}

a_data variable have string type, i can not use it.

Can you explain, how can i use sub-array in $dataBuilder->addData for iOS json/object type?

brozot commented 7 years ago

Hi,

Your question need that I investigate a lot, I will try to find a solution and I will come back to you

Best Regards

himalayaahuja commented 4 years ago

anything on this..? facing the same issue.. on laravel 5.8