beck
beck

Reputation: 3027

ConnectionRequest is not working in iOS

I've a year & a half old app to update. It was written in statemachine. Now I added a few things but the connectionRequest doesn't seem to work in iOS (which was built for iOS debug). I built it in android and it works very well.

 public void connectionForLogin(String username, String password) {
    ConnectionRequest cr = new ConnectionRequest() {

        @Override
        protected void readResponse(InputStream input) throws IOException {
            JSONParser jSONParser = new JSONParser();
            Map<String, Object> parsedData = jSONParser.parseJSON(new InputStreamReader(input));
            ArrayList<Map<String, Object>> response = (ArrayList<Map<String, Object>>) parsedData.get("root");
            if (response != null) {
                for (Map<String, Object> element : response) {
                    success = (String) element.get("login");
                    msg = (String) element.get("msg");

                    ArrayList<Map<String, Object>> userInfoArray = (ArrayList) element.get("user_info");
                    Storage.getInstance().writeObject("userInfo", userInfoArray);
                }
            }
        }

        @Override
        protected void postResponse() {
            super.postResponse(); 
        }

        @Override
        protected void handleErrorResponseCode(int code, String message) {
        }

        @Override
        protected void handleException(Exception err) {
        }

        @Override
        protected void handleIOException(IOException err) {
        }

        @Override
        protected void handleRuntimeException(RuntimeException err) {
        }
    };
    cr.setPost(true);
    cr.setDuplicateSupported(true);
    cr.setTimeout(30000);
    AllUrl au = new AllUrl();
    InfiniteProgress ip = new InfiniteProgress();
    Dialog d = ip.showInifiniteBlocking();
    cr.setDisposeOnCompletion(d);
    cr.setUrl(http://zzz.com/api/logins/match? + "username=" + username + "&password=" + password);
    NetworkManager.getInstance().addToQueueAndWait(cr);
 }

Upvotes: 2

Views: 47

Answers (1)

Diamond
Diamond

Reputation: 7483

This may be due to new Apple regulations that prevents apps from fetching data from non secure URL http. You can fix this temporarily by adding below build hint:

ios.plistInject=<key>NSAppTransportSecurity</key><dict><key>NSAllowsArbitraryLoads</key><true/></dict><key>CFBundleURLTypes</key><array><dict><key>CFBundleURLName</key><string>com.mycompany.myapp</string></dict><dict><key>CFBundleURLSchemes</key><array><string>MyApp</string></array></dict></array> 

Note that your app may be rejected if connected to a non secure URL.

Upvotes: 1

Related Questions