Saturday, March 17, 2018

Subscribe Laravel events on Android/Api - development

Subscribe Laravel events on Android/Api

Does anyone has an idea how i can achieve this.

I have done broadcast authentication already;

     Broadcast::routes(['middleware' => 'auth:api']);

and in the channel i have:

Broadcast::channel('Shops-{id}', function ($user, $id) {
         return true;
  });

so how should my android Events looks like:

HttpAuthorizer authorizer = new 
    HttpAuthorizer("http://serverip/broadcasting/auth");
    PusherOptions options = new PusherOptions().setAuthorizer(authorizer);
   Pusher pusher = new Pusher(1234567891011, options);

  Channel channel = pusher.subscribe("Shops-52");

 channel.bind("AppEventsCustomerOrderNewItem", new SubscriptionEventListener() {
 @Override
 public void onEvent(String channelName, String eventName, final String data) {
    System.out.println(data);
   }
});

pusher.connect();

The above is not working though i can see that i have subscribed on the channel in the pusher’s debug console.

The events seems not to be reaching the phone.



from Laravel Questions and Answers https://laravelquestions.com/laravel/subscribe-laravel-events-on-android-api/
via Lzo Media

No comments:

Post a Comment