{"id":696,"date":"2020-08-07T15:27:21","date_gmt":"2020-08-07T15:27:21","guid":{"rendered":"http:\/\/www.jontrinder.com\/blog\/?p=696"},"modified":"2020-08-07T15:27:21","modified_gmt":"2020-08-07T15:27:21","slug":"sending-udp-packets-with-phonegap-and-the-in-app-browser","status":"publish","type":"post","link":"https:\/\/www.jontrinder.com\/blog\/?p=696","title":{"rendered":"Sending UDP Packets with Phonegap and the In App Browser"},"content":{"rendered":"\n<p>To send some instructions to a server process I needed to send UDP  packets from an Android device. Normally I would \u201cgo native\u201d and  java\/kotlin but for this one I tried phonegap. This is a reminder of a couple of tweaks needed.<\/p>\n\n\n\n<p>You need this package:-<\/p>\n\n\n\n<p>cordova-plugin-chrome-apps-sockets-udp <\/p>\n\n\n\n<p> ie cordova plugin add cordova-plugin-chrome-apps-sockets-udp <\/p>\n\n\n\n<p>I also wanted to check a web page so used the cordova &#8220;<a href=\"https:\/\/cordova.apache.org\/docs\/en\/latest\/reference\/cordova-plugin-inappbrowser\/\">in app browser<\/a>&#8220;<\/p>\n\n\n\n<p>That worked on older Android but on on newer versions gave the error net::ERR_CLEARTEXT_NOT_PERMITTED .<\/p>\n\n\n\n<p>To fix that needs tweaks in the  project config.xml needed the xml android namespace adding as below<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;widget id=\"com.whatever.app\" version=\"1.0.0\" \nxmlns=\u201dhttp:\/\/www.w3.org\/ns\/widgets\u201d \nxmlns:android=\u201dhttp:\/\/schemas.android.com\/apk\/res\/android\"\nxmlns:gap=\"http:\/\/phonegap.com\/ns\/1.0\"><\/code><\/pre>\n\n\n\n<p>and in the platform stanza<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;platform name=\"android\">\n&lt;edit-config file=\"app\/src\/main\/AndroidManifest.xml\" mode=\"merge\"   target=\"\/manifest\/application\">\n  &lt;application android:usesCleartextTraffic=\"true\" \/>\n&lt;\/edit-config>\n........rest of the platform entry\n&lt;\/platform><\/code><\/pre>\n\n\n\n<p>For more info on this at stackoverflow see <a href=\"https:\/\/stackoverflow.com\/questions\/54752716\/why-am-i-seeing-neterr-cleartext-not-permitted-errors-after-upgrading-to-cordo\">here<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>To send some instructions to a server process I needed to send UDP packets from an Android device. Normally I would \u201cgo native\u201d and java\/kotlin but for this one I tried phonegap. This is a reminder of a couple of &hellip; <a href=\"https:\/\/www.jontrinder.com\/blog\/?p=696\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[45,81,80,1],"tags":[29,109],"class_list":["post-696","post","type-post","status-publish","format-standard","hentry","category-android","category-coding","category-computing","category-uncategorized","tag-coding","tag-phonegap"],"_links":{"self":[{"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/696","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=696"}],"version-history":[{"count":5,"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/696\/revisions"}],"predecessor-version":[{"id":701,"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/696\/revisions\/701"}],"wp:attachment":[{"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=696"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=696"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=696"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}