i create a fresh new worklight (5.0.6) project with jquerymobile (1.2.0), add the blackberry 6-7 environment, nothing else.
here is the wlcommoninit code.
function wlCommonInit(){
WL.Client.connect({
onSuccess: onConnectSuccess,
onFailure: onConnectFailure
});
}
function onConnectSuccess(){alert("ok");}
function onConnectFailure(){alert("ko");}
i get the following issue when i preview the app.
wlclient init started worklight.js:1118
before: app init onSuccess worklight.js:1118
Request [/apps/services/api/cm2/blackberry/init] worklight.js:1118
after: app init onSuccess worklight.js:1118
wlclient init success worklight.js:1118
Failed to load resource: the server responded with a status of 403 (Forbidden)
`http://localhost:8080/apps/services/api/cm2/blackberry/init`
[/apps/services/api/cm2/blackberry/init] failure. state: 403, response: undefined worklight.js:1118
the common environment works fine.
am i missing something ?
thanks for your help
There is a known defect when previewing the BlackBerry 6-7 (and also Windows Phone); there is improper handling of the 403 status response (it's OK to get it, but the handling mishandles it...).
The app should work correctly on an actual device (probably simulator as well).
Related
I have a web app developed in node.js, and now I am starting to create a mobile app from it using capacitorjs. In the web app I used handlebars to parameterize views and then served them using res.render(). With capacitorjs, it seems that the way to proceed is to precompile the views (templates and partials), and just make AJAX calls to the server to get the data and then create html using Handlebars.template.view(data), etc. So far so good!
For the development phase I have the api server running on the local machine. I had been using a self-signed SSL certificate on the local machine, and it had given me no trouble for the past few months, after having previously added my own Certificate Authority's certificate to the keychain on my MacOS machine, and after accepting the development server's self-signed certificate in the browsers. With capacitorjs, after having organized web assets in a www directly and creating an index.html file, I started the process of creating the mobile app with iOS using:
npx cap add iOS
open ios/App/App.xcworkspace
I found that the iOS simulator does not like to access anything from an https server with a self-signed certificate despite the fact that I added my certificate authority's certificate to the device's Settings->General->About->Certificate Trust Settings and enabled full trust for root certificates (a list that includes my certificate authority's certificate). After struggling with this for a while, I decided to run my development server as http, at least initially to get the ball rolling. It still did not work, and I figured it is because of CORS, so I added this middleware to my app stack:
import cors from 'cors';
var corsOptions = {
origin: 'capacitor://localhost',
optionsSuccessStatus: 200
}
app.use(cors(corsOptions));
This seems to work, although fleetingly! Here's a simple AJAX request I make to test whether I can retrieve the data from the development server:
document.getElementById('test').addEventListener('click', event => {
console.log('test clicked');
console.log(`apiServer: ${apiServer}`);
$.ajax({
url: `${apiServer}/api/test`,
type: 'get',
data: {},
success: function (data) {
console.log(`/api/test`, data)
},
error: function (err) {
console.log(`error: `, err);
}
});
});
Over on the server, the route looks like this:
router.get('/api/test', function(req, res, next) {
res.send({
title: 'API Test',
apiResponse: 'success',
});
});
After starting the iOS simulator, I get my app's home screen with the "test" button. When I click it the first time, it works fine. The log shows this:
⚡️ [log] - apiServer: http://192.168.1.101:3000
⚡️ [log] - /api/test {"title":"API Test","apiResponse":"success"}
Subsequent clicks, however, give an error:
⚡️ [log] - apiServer: http://192.168.1.101:3000
⚡️ [log] - error: {"readyState":0,"status":0,"statusText":"error"}
I am not sure why. I added a second API test route and hit that on the second click, and still get the same error. That is, the first GET request works, subsequent ones don't. Over on the server I can see that it responds with a status 200 for the first GET request, and sometimes also for the second GET request (whether I hit the same test route or two different routes), however, on the iOS simulator only the first hit gets the data, the second results in error. Subsequent GET requests (third, fourth, . . ) do not get registered by the server, and the simulator continues to give the same error:
⚡️ [log] - apiServer: http://192.168.1.101:3000
⚡️ [log] - error: {"readyState":0,"status":0,"statusText":"error"}
I am stuck, and could use help. Thanks for reading!
Update: I have tried various settings for Application Transport Security as recommended in various discussions on Stack Overflow and Apple Developer Forum, including:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
</dict>
And, various combinations of these settings:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
<key>NSAllowsArbitraryLoadsInWebContent</key><true/>
<key>NSAllowsLocalNetworking</key><true/>
<key>NSExceptionDomains</key>
<dict>
<key>192.168.1.101:3000</key>
<dict>
<key>NSIncludesSubdomains</key><true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key<true/>
<key>NSExceptionRequiresForwardSecrecy</key><true/>
</dict>
</dict>
</dict>
But nothing seems to help. Surprisingly, if I set NSAllowsArbitraryLoads to NO, and remove all other keys in ATS, the behaviour remains the same. That is, the first AJAX request is successful, while subsequent ones are not and give the same error as earlier. ATS settings in Info.plist don't seem to matter!
It seems like this wasn't an issue of permissions to access an external API server. I wrapped up the AJAX call within a function, makeRequest(), and just tried to execute it repeatedly using setInterval():
setInterval(() => { makeRequest(); }, 2000);
This worked: repeated GET requests to the API (whether on my local server at http://192.168.1.101:3000 or on an externally available public server such as https://emojihub.herokuapp.com/api/random) are now successful. So, something seemed to have been interfering with the AJAX requests when the button is clicked: never the first time when the simulator loads the app, but subsequent times. I then added event.preventDefault() to the top of the button event listener, and this has resolved the problem.
I want to download some game(for using offline and for keep it in archive) which built with Unity in WebGL format. I tried downloading it with wget and HTTrack,but when I running it on local web server I only get errors like this: "An error occurred running Unity content".
In Chrome Developer Console I see this:
Failed to load resource: the server responded with a status of 404 (Not Found) UnityLoader.js:3 Invoking error handler due to Script error. index.html:1 Uncaught SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse () at XMLHttpRequest.t.onload (UnityLoader.js:4) index.html:1 Unchecked runtime.lastError: The message port closed before a response was received
Is it possible to download Unity WebGL game? If yes, how?
I worried that if this is not possible, that can lead to losing a lot of content,because of sites sometimes went down.
I've made an application in Ionic V4 and then build the same using cordova plugin (not capacitor). First page of my application is login where I'm getting values from form fields and sending it to login method where I am making a POST call to server.
loginUrl = 'http://localhost:3000/login';
errorLog: any;
login(form) {
const user = form.values;
this.httpClient.post(this.loginUrl, user).subscribe( response => {
this.toastController.create({message:'Login Successful', duration: 1000}).then(toast=> toast.present());
}, error => {
this.errorLog = error;
this.toastController.create({message:'Some Error Occured', duration: 1000}).then(toast=> toast.present());
})
}
Also I'm printing that error log in login page because once we make build, its hard to debug in device using Android Studio or Xcode.
So I'm printing error log like this
<h3>{{errorLog | json}}</h3>
I'm not getting error from POST call in case of running the application in web browser as well as in android. Getting error in iOS when I tried to make build and using Xcode, deployed into my iPad.
It's working fine in GET HTTP calls because previously I've tested GET HTTP calls in same but not working in POST HTTP calls.
Its returning 500 internal server error. Error object looks like
{
"statusText": "OK",
"status": 500,
"url": "http://localhost:3000/login",
"ok": false,
"name": 'HttpErrorResponse',
"message": "Http failure response for http://localhost:3000/login: 500 OK",
...
}
How I make build is
ionic build --prod --release
ionic cordova platform remove ios (if platform already exist).
ionic cordova platform add ios
ionic cordova prepare ios
Then I open the same ios folder into Xcode, select the developer account, connect my iPad and run it.
Were you able to resolve it?
I faced similar situation and here's how I got around it.
In capacitor.config.json file we need to specify 'server' from where we are getting the Api data.
"appId": "com.yoursite",
"appName": "Your Site",
"bundledWebRuntime": false,
"npmClient": "npm",
"webDir": "www",
"cordova": {},
//This part mentioned below is important.
"server": {
"url": "https://yoursite.com",
"allowNavigation": ["yoursite.com", "*.yoursite.com"]
},
Hope this helps.
I see this error:
Error: This operation is not supported in the environment this
application is running on. "location.protocol" must be http, https or
chrome-extension and web storage must be enabled.
When I use:
firebase.auth().signInWithPopup(provider)
.then(function(result) {
console.log(result);
})
.catch(function(error) {
console.log('popup', error);
//webSettings.setDomStorageEnabled(true);
firebase.auth().signInWithRedirect(provider)
.then(function(result) {
console.log(result);
})
.catch(function(error) {
console.log('redirect', error);
firebase.auth().signInAnonymously().catch(function(error) {
console.log('anonymous', error);
});
});
});
The first two login attempts via popup and redirect fail. It seems to happen only on iOS Safari.
I see others reporting the issue with Cordova, but I don't see an answer and I'm only using web and firebase. Not Cordova or ionic etc.
The anonymous login works on iOS but that is only a test and not what we want to use to use.
If you want to test it you can use https://meetup-reporter.firebaseapp.com/ from Safari on iOS
An example dump of the error object from the returned Promise is:
{"code": "auth/operation-not-supported-in-this-environment",
"constructor": function (a, b)
{this.code="auth/"+a;this.message=b||Xf[a]||"";}, "F": function ()
{return{code:this.code,message:this.message}}, "line": 44, "message":
"This operation is not supported in the environment this application
is running on. \"location.protocol\" must be http, https or
chrome-extension and web storage must be enabled.", "sourceURL":
"https://meetup-reporter.firebaseapp.com//firebase/4.1.2/firebase-auth.js",
"stack":
"https://meetup-reporter.firebaseapp.com//firebase/4.1.2/firebase-auth.js:44:638\nhttps://meetup-reporter.firebaseapp.com//firebase/4.1.2/firebase-auth.js:45:258\nA#https://meetup-reporter.firebaseapp.com//firebase/4.1.2/firebase-auth.js:44:545\nD#https://meetup-reporter.firebaseapp.com//firebase/4.1.2/firebase-auth.js:45:242\nsignInWithPopup#https://meetup-reporter.firebaseapp.com//firebase/4.1.2/firebase-auth.js:241:48\na#https://meetup-reporter.firebaseapp.com/__/firebase/4.1.2/firebase-auth.js:260:432\nhttps://meetup-reporter.firebaseapp.com/scripts/main.js:430:36",
"toJSON": function () {var
a=Array.prototype.slice.call(arguments);a:{var
e=Array.prototype.slice.call(a);var l=0;for(var
n=!1,C=0;Cl||l>=fk.length)throw new N("internal-error","Argument
validator received an unsupported number of arguments.");e=fk[l]+"
argument "+(e.name?'"'+e.name+'" ':"")+"must be "+e.N+".";break
a}e=null}}if(e)throw new N("argument-error",d+" failed: "+e);return
b.apply(this,a);}}
signInWithRedirect actually works in Cordova now: https://firebase.google.com/docs/auth/web/cordova
signInWithPopup and signInWithRedirect should also work for iOS7 and up. I just tested both on an iOS 7 device and they both work. What you are experiencing is likely to the fact that you are using this operation in Safari Private/Incognito mode where web storage is disabled. These operations depend on web storage in order to securely communicate the OAuth result to the parent page. You will need to ask your users to switch to regular mode when this happens, or you can use the Google Sign-in JS SDk to get the OAuth credential and then signInWithCredential. I think it may work in incognito mode.
I'm using the CastHelloText-chrome example and am able to get it all working just fine from the Chrome browser on my desktop, however, when I try to use Chrome on my iOS device, I receive the following error when trying to create a session:
{ "code": "channel_error", "description": "The operation couldn't be completed. (com.google.chrome.ios.cast error 2.)" }
This error happens when executing the following:
chrome.cast.requestSession(function(e) {
session = e;
session.sendMessage(namespace, message, onSuccess.bind(this, "Message sent: " + message), onError);
}, onError);
Specifically, this seems to happen on the requestSession function call (the nested callback never actually executes).
Everything up until this point seems to work. In fact, on my iOS device, I even receive the popup asking where to cast to (Chromecast) and once I select it, my Chromecast does indeed display my custom receiver. However, I still receive that error message and never get a session object, so I can't send messages to the receiver.
Like I said, this seems to work fine on my desktop Chrome browser, but does not work on my iOS Chrome browser. Does this sample not work on iOS devices? Is there a way to make it work?
Chrome on desktop and Chrome on mobile are not the same. You need to use the iOS API. Use the sample app for CastHelloText-ios as a reference.