Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation update #2

Open
panksi opened this issue Oct 6, 2021 · 4 comments
Open

Documentation update #2

panksi opened this issue Oct 6, 2021 · 4 comments

Comments

@panksi
Copy link

panksi commented Oct 6, 2021

Hi,

an example of how the plugin is instanced and how it works would be nice. ex. now I have this issue:
image

And dunno what to do with it :)

I am using the latest Ionic with VUE and the latest Capacitor

please help, thanks upfront

@panksi
Copy link
Author

panksi commented Oct 7, 2021

I just realized that nothing has changed in this fork except the metadata :) so I would assume it still has the same problem as the plugin from the main repo... Not a bugger, I'll try to repack the plugin to match capacitor 3+imports. If you do so in the meantime, please let me know not to waste the time on the same thing. thanks

@tscizzlebg
Copy link

@panksi Did you ever make this compatible with capacitor 3? (Or find anything else that already is?)

@acolytec3
Copy link

acolytec3 commented Apr 4, 2022

After much trial and error, I've been able to get this plugin to work with react (admittedly not Vue but hopefully the general steps will work for you too).

Once you install the plugin, a couple of set up steps:

  1. Make sure that the webDir key in capacitor.config.js refers to the directory your index.html file is in (public for react apps if doing development or build if building the app first)
  2. Run npx cap sync and then npx cap copy to ensure the plugin files are copied to the corresponding mobile app platform directories (android or ios).

Then, use it as below:

First, you have to import it as:
import { UDP } from '@frontall/capacitor-udp'
since it uses a named export.

Then, create a socket and bind it to a port:

const socket = UDP.create()
await UDP.bind({socketId: socket.socketId, socket.ipv4, port: 0})

Then set up listeners or send stuff:

UDP.addListener("receive", ({socketId, buffer}) => {
    console.log('got a message', buffer)
    UDP.send({ socketId: socket.socketId, address: '192.168.1.100', port: 100, buffer: 'hello friend'})
})

Something like this.

@panksi
Copy link
Author

panksi commented Apr 5, 2022

@panksi Did you ever make this compatible with capacitor 3? (Or find anything else that already is?)

Sorry for the late reply bro, for me it turned out that the complete Java part of the app (opening the socket for Android) was missing, so I abandoned the experiment. Maybe this from comment bellow will work...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants