0

I've setup an heroku account with the following credentials : heroku credentials

and the following is my index.js setup :

var express = require('express');  // find this line in the file
var cors = require('cors') // add this line below it
var ParseServer = require('parse-server').ParseServer;
var path = require('path');

var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI ;

if (!databaseUri) {
  console.log('DATABASE_URI not specified, falling back to localhost.');
}

var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://heroku_vpgrmmf2:xxx@xxx.mlab.com:53735/heroku_vpgrmmf2',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || '',
  masterKey: process.env.MASTER_KEY || '',
  serverURL: process.env.SERVER_URL || 'https://myapp.herokuapp.com/parse',  
  clientKey: process.env.CLIENT_KEY || '',
  javascriptKey: process.env.JAVASCRIPT_KEY || '',
  liveQuery: {
    classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
  }
});
var app = express();
app.use(cors());

Obviously filled in with the same credentials as the Heroku server. I've tested it on this page and it seems to be working : I get the following message

test

However, when I run my swift app with this setup for the app delegate :

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { Parse.enableLocalDatastore() let configuration = ParseClientConfiguration(block: { (ParseMutableClientConfiguration) -> Void in ParseMutableClientConfiguration.applicationId = "" ParseMutableClientConfiguration.clientKey = "" ParseMutableClientConfiguration.server = "https://myapp.herokuapp.com/parse" })

// Swift 3.0
Parse.initialize(with: configuration)
Parse.setApplicationId("", clientKey: "")

PFFacebookUtils.initializeFacebook(applicationLaunchOptions: launchOptions)

PFUser.enableAutomaticUser()

let defaultACL = PFACL();
defaultACL.getPublicReadAccess = true

PFACL.setDefault(defaultACL, withAccessForCurrentUser: true)

if application.applicationState != UIApplicationState.background {
    let preBackgroundPush = !application.responds(to: #selector(getter: UIApplication.backgroundRefreshStatus))
    let oldPushHandlerOnly = !self.responds(to: #selector(UIApplicationDelegate.application(_:didReceiveRemoteNotification:fetchCompletionHandler:)))
    var noPushPayload = false;
    if let options = launchOptions {
        noPushPayload = options[UIApplicationLaunchOptionsKey.remoteNotification] != nil;
    }
    if (preBackgroundPush || oldPushHandlerOnly || noPushPayload) {
        PFAnalytics.trackAppOpened(launchOptions: launchOptions)
    }
}
return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)}

(obviously filled with the right credentials too). It doesn't seem to be connected to the server as I get this error :

error

I've been trying to figure out what am I doing wrong for the past week but I wasn't able to. Does anybody have any idea of what I could be doing wrong? Thanks in advance.

EDIT: Also, this is the code I added to my info.plist file :

<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSExceptionDomains</key>
        <dict>
            <key>myapp.herokuapp.com/parse</key>
            <dict>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
                <key>NSExceptionMinimumTLSVersion</key>
                <string>TLSv1.2</string>
                <key>NSExceptionRequiresForwardSecrecy</key>
                <true/>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSRequiresCertificateTransparency</key>
                <string></string>
                <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
                <false/>
                <key>NSThirdPartyExceptionMinimumTLSVersion</key>
                <false/>
                <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
                <true/>
            </dict>
        </dict>
    </dict>
Giulio Colleluori
  • 1,261
  • 2
  • 10
  • 16
  • did you add the domain name https://myapp.herokuapp.com/parse to your info.plist? see http://stackoverflow.com/questions/30731785/how-do-i-load-an-http-url-with-app-transport-security-enabled-in-ios-9 ... could you try regular CURL command to test if this is related to iOS sdk or just server setup? – Mazel Tov Feb 03 '17 at 22:57
  • I did now, adding the following to my info.plist didn't quite help unfortunately. Would you mind explaining what do you mean by regular CURL command? Request something from the server with curl from the terminal? How would I go about that? Thanks. @MazelTov – Giulio Colleluori Feb 03 '17 at 23:17
  • something like this just to test the API server... `curl -X GET \ -H "X-Parse-Application-Id: ${APPLICATION_ID}" \ -H "X-Parse-REST-API-Key: ${REST_API_KEY}" \ https://api.parse.com/1/classes/GameScore/Ed1nuqPvcm` and run this command in terminal (you have to edit it first with your setup) – Mazel Tov Feb 04 '17 at 00:07
  • `curl: (6) Could not resolve host: -H curl: (6) Could not resolve host: X-Parse-Application-Id` It's returning this error. Do I need to specify my server url somewhere? (myapp.herokuapp.com/parse) @MazelTov – Giulio Colleluori Feb 04 '17 at 00:55
  • I figured it out, I wasn't supposed to use the backlash "/". Now though it returns the following : `Parse.com has shutdown` should I try with my server url? – Giulio Colleluori Feb 04 '17 at 02:18
  • so I changed it and replaced the url with my server url like this : `curl -X GET -H "X-Parse-Application-Id: myappid" -H "X-Parse-Client-Key: myclientkey" https://myapp.herokuapp.com/parse` but now I get this : `Cannot GET /parse` - Does that mean anything? Thanks @MazelTov – Giulio Colleluori Feb 04 '17 at 02:24

1 Answers1

0

I eventually figured it out : I had to delete this line from the appDelegate :

Parse.setApplicationId("myappid", clientKey: "myclientkey")

And now it works, not sure why but I'm glad.

Giulio Colleluori
  • 1,261
  • 2
  • 10
  • 16