davibennun / laravel-push-notification

Laravel package to enable sending push notifications to devices
1.23k stars 259 forks source link

Call to undefined method Davibennun\LaravelPushNotification\App::getAdapter() #62

Open MwirabuaTimothy opened 9 years ago

MwirabuaTimothy commented 9 years ago

I just installed the package and did a simple implementation on my router as below:

Route::get('pusher', function(){
    $deviceToken = '1234567890';
    $push = PushNotification::app('appNameAndroid')
        ->to($deviceToken)
        ->send('Hello World, i`m a push message');

    $response = $push->getAdapter()->getResponse();
    // $response = $push->getAdapter()->getFeedback();
    return $response;
});

I got the error:

Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN)
Call to undefined method Davibennun\LaravelPushNotification\App::getAdapter()

highlighting the $response = ... line

I have also published my config file and added the android apiKey. What could I be missing?

odin88 commented 9 years ago

can share your composer.json files ?

i can get the respond just fine.

    $devices = PushNotification::DeviceCollection($gcm_devicecollection);

    $message = PushNotification::Message(null,array(
        'collapse_key' => "New message available",
        'priority' => 'high'
    ));

    $collection = PushNotification::app('syncAndroid')
    ->to($devices)
    ->send($message);

    foreach ($collection->pushManager as $push) {
        $response = $push->getAdapter()->getResponse();

        Log::info('response '.var_export($response, true));
    }
MwirabuaTimothy commented 9 years ago

Yes.. here is what I have:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "laravel/framework": "4.2.*",
        "way/generators": "2.*",
        "cartalyst/sentry": "2.1.*",
        "madewithlove/laravel-oauth2": "0.4.*",
        "jenssegers/agent": "*",
        "j42/laravel-firebase": "dev-master",
        "fzaninotto/faker": "1.4.*@dev",
        "jenssegers/date": "~2.0",
        "intervention/image": "~2.1",
        "league/csv": "~7.0",
        "sly/notification-pusher": "~2.2",
        "davibennun/laravel-push-notification": "dev-master"
    },
    "autoload": {
        "classmap": [
            "app/commands",
            "app/controllers",
            "app/models",
            "app/database/migrations",
            "app/database/seeds",
            "app/tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    },
    "minimum-stability": "stable"
}
MwirabuaTimothy commented 9 years ago

Error here: http://localbuzz.co.ke/pusher

javiervelaz commented 8 years ago

could you solved this? i have the same error