Navigation

    Monaca & Onsen UI
    • Register
    • Login
    • Search
    • Tags
    • Users
    • Blog
    • Playground
    1. Home
    2. scastagnoli
    S
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups
    Save
    Saving

    scastagnoli

    @scastagnoli

    0
    Reputation
    4
    Posts
    412
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    scastagnoli Follow

    Posts made by scastagnoli

    • Barcode scanner and REST API

      Hi!
      I think it’s a common problem but I really cannot find a solution searching on the www.
      Does anyone have tried to use barcode scanner and send the informations cathced to a REST API in the same application?
      I’ve tried using HTTPS and HTTP REST servers, in HTTP case I’ve changed config.xml to make it work but that change seems not compatible with barcode scanner plugin: barcode scanner always crashes after i’ve allowed it to access camera.
      Barcode scanner default example works alone, REST API send data works alone, but they don’t work together: when put them together REST send works but camera access crashes. Is it so for all You too?

      I’ve also tried using websocket, but it seems online emulator doesn’t support it…
      This is code I’ve used to send data:

      sendData = function () {	
              const get = async () => { 
                const response = await fetch(URLtoRESTapi, { 
                  method: 'POST',
                  headers: {
                    'Content-Type': 'application/json;charset=utf-8'
                  },
                  body: JSON.stringify(dataToSend)
                }
                );
                const json = await response.json();//my REST API returns {"response": "Ok"}
                ons.notification.alert(json.result);
              }
              get();
      }  
      

      This is what I have modified in config.xml in <platform name="android"> section.

      <edit-config file="AndroidManifest.xml" target="/manifest/application" mode="merge">
      <application android:usesCleartextTraffic="true" />
      </edit-config> 
      

      and this is my change at the top of config.xml:

      <widget xmlns:android="http://schemas.android.com/apk/res/android">
      

      I’ve used the defautl example for barcode scanner.

      Thank you in advance!
      Stefano

      posted in Developer Corner
      S
      scastagnoli
    • Waiting for Monaca Debugger connecting to apipa adress

      Hi,
      Whe I start:

      monaca debug
      

      from Local Toolkit it says:

      Waiting for Monaca Debugger connecting to 169.254.44.238:8001
      

      My correct address is 192.168.178.107, and I can use LAN and Internet resources without problems.
      How can I tell the debugger to listen to my IP address?
      My firewall is off, my smartphone says it has found a PC on the LAN but it runs on timeout.

      What can I do?
      Cheers!

      posted in Monaca Tools
      S
      scastagnoli
    • RE: jsonp error acccessing LAN resource

      @emccorson said in jsonp error acccessing LAN resource:

      Is your device running Android 9? HTTP communication is prohibited on Android 9 so you will need to use HTTPS

      Thank you for your reply!
      I’ve converted my HTTP server in HTTPS. I’m using Flask and it tells from debug console:

      • Running on https://0.0.0.0:5000/ (Press CTRL+C to quit)

      I’m monitoring my LAN using WireShark but nothing seems to start from my smartphone. Instead I can see all packets generated from another application (I’m using TCP/UDP test tool).

      I can also say that using “Custom Build Debugger” it works correctly. How can I create an operating APK with jsonp without using Custom Build Debugger?

      posted in Monaca Tools
      S
      scastagnoli
    • jsonp error acccessing LAN resource

      Good Morning,
      I’m an italian teacher building an educational app for my students.
      I’m quite new here and I’ve tried the following:
      config.xml: row <access origin="*" /> (manually added)
      index.html:

      • <meta http-equiv=“Content-Security-Policy” content=“default-src * data:; style-src * ‘unsafe-inline’; script-src * ‘unsafe-inline’ ‘unsafe-eval’; connect-src *”> (manually added)

      • and: $.ajax({ url: "http://192.168.178.107:5000", jsonp: "jsonpcallback", dataType: "jsonp", type: "get", data: { prodotti: JSON.stringify(prodotti) }, success: function(data){ console.log(data.result); }, error: function(data){ var debug = document.querySelector("#debug").innerHTML = JSON.stringify(data); } })

      cordova-plugin-whitelist: enabled

      I would access LAN server resource http://192.168.178.107:5000. I have no problem using my PC browser, but I always receive the following in the a <div id = “debug”></div> once I try APK generated with Monaca.io:

      {"readyState":4, "status": 404; "statusText": "error"}
      

      I think the problem is on app side because I cannot see any request from my smartphone using WireShark.

      I’m using pro-plan (for this month). What can I do?

      Best Regards,
      Stefano

      posted in Monaca Tools
      S
      scastagnoli