This is a laravel-echo plugin for native applications made with nativescript
For more information read Laravel Broadcast.
Necesary api authentication in your laravel backend application.
Modify the file where the following line Broadcast::routes()
Example in app/Providers/BroadcastServiceProvider.php
class BroadcastServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Broadcast::routes(['middleware' => 'auth:api']);
require base_path('routes/channels.php');
}
}
Describe your plugin installation steps. Ideally it would be something like:
$ tns plugin add nativescript-laravel-echo
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
class Event implements ShouldBroadcast
{
/**
* Information about the shipping status update.
*
* @var string
*/
public $data; //data show in console.dir as data
}
Javascript
const TnsEcho = require('nativescript-laravel-echo').TnsEcho;
const token = 'Asdsd3dsdsTytf';//Your token
const options = {
//....
broadcaster: 'socket.io',// pusher,
headers: {
auth: {
bearer: `Bearer ${token}`
}
}
}
const Echo = new TnsEcho(options)
Echo.channel('YourChannel').listen('Event', e => {
console.dir(e)
})
//presence channel for others
const http = require('tns-core-modules/http');
http.request({
//....
headers: {
//...
'X-Socket-Id': Echo.socketId() // get socket id
}
});
TypeScript
import { TnsEcho } from 'nativescript-laravel-echo';
const token = 'Asdsd3dsdsTytf';//Your token
const options = {
//....
broadcaster: 'socket.io',// pusher,
headers: {
auth: {
bearer: `Bearer ${token}`
}
}
}
this.Echo = new TnsEcho(options)
this.Echo.channel('YourChannel').listen('Event', e => {
console.dir(e)
})
//presence channel for others
import * as http from 'tns-core-modules/http';
http.request({
//....
headers: {
//...
'X-Socket-Id': this.Echo.socketId() // get socket id
}
})
These are each of the parameters that can go in the object options.
Property | Default | Description |
---|---|---|
broadcaster | pusher | Driver for broadcast pusher or socket.io |
host | null | Your host only socket.io |
authEndpoint | /broadcasting/auth | Your auth endpoint only for Pusher |
key | null | Your api key of Pusher App |
cluster | null | Your cluster of Pusher App |
auth | auth:{headers:{}} | Necesary in private an presence channel's with Authorization header |
namespace | App.Events | The namespace backend events |
debug | false | Enable debug only socket.io broadcaster |
forceWebsockets | false | Force WebSockets |
Apache License Version 2.0, January 2004
一.准备工作 1.下载微信官方PHP的SDK,里面有个rootca.pem要用到,在php.ini里配置curl.cainfo=你存放rootca.pem的绝对路径,重启PHP 2.composer集成easywechat的laravel版本,具体怎么使用点这里 2.1 composer require "overtrue/laravel-wechat:~3.0" 2.2 Laravel 应用 注
您好,我无法在laravel homestead(vagrant)上安装v8js 看完这两个tuts 我启动了以下命令 $sudo apt-get install libv8-dev libv8-dbg g++ cpp $sudo pecl install v8js-0.1.3 还请注意,当我要求输入libv8的安装前缀时,我输入了/ opt / v8 编辑:按照用户的要求,我发布错误代码并删除相
NativeScript 可以使用 Javascript,CSS, XML 创建真正的 Native 跨平台应用,支持 iOS Android,NativeScript 将您的跨平台代码翻译成目标平台的代码。 UI 使用 XML 描述,CSS 样式,在编译时将 UI 转化成本地原生代码,最终得到正在的 Native 原生应用。 Telerik 公开了用于创建安卓、iOS和Windows Unive
NativeScript Command-Line Interface The NativeScript CLI lets you create, build, and deploy NativeScript-based apps on iOS and Android devices. Get it using: npm install -g nativescript What is Native
NativeScript-Snackbar �� �� �� NativeScript plugin for Material Design SnackBar component. Installation: NativeScript 7+:tns plugin add @nstudio/nativescript-snackbar NativeScript version prior to 7:t
Nativescript-Ripple This plugin aims to bring a native (or close to native) ripple implementation on Android and iOS. The android version uses a RippleDrawable and conserves the previous background, a
NativeScript-FloatingActionButton NativeScript plugin for Material Design Floating Action Button UI component. Installation Nativescript 7+: ns plugin add @nstudio/nativescript-floatingactionbutton Na
NativeScript CardView A NativeScript plugin to provide an XML widget to implement the Material Design CardView component. Installation NativeScript 7+: ns plugin add @nstudio/nativescript-cardview Nat