I deployed a parse server to AWS Elastic Beanstalk and rewrite my iOS app in AppDelegate.swift. But i only rewrited the ParseMutableClientConfiguration.server so, the APPID and CLIENTKEY is still the same ID and KEYS that are in parse.api.com
It this a correct way to configure my ID and KEYS and server? or do i need to generate a new APPID by myself in this case?
let config = ParseClientConfiguration(block: {
(ParseMutableClientConfiguration) -> Void in
ParseMutableClientConfiguration.applicationId = APP_ID;
ParseMutableClientConfiguration.clientKey = CLIENT_ID;
ParseMutableClientConfiguration.server = "EC2 DNS"
});
Parse.initializeWithConfiguration(config)
Yes this is fine. With swift 3 its done like this.
// Init Parse
let configuration = ParseClientConfiguration {
$0.applicationId = "XXX"
$0.clientKey = "XXX"
$0.server = "XXX"
$0.isLocalDatastoreEnabled = true
}
Parse.initialize(with: configuration)
Related
I created my own VPN server(IKEV2) and I successfully run it on my iPhone by the Settings.(see the screenshot):
Then, I want to run the VPN with the same config in the iOS application.
I wrote this config:
let p = NEVPNProtocolIKEv2()
p.useExtendedAuthentication = true
p.serverAddress = "133.37.212.77"
p.remoteIdentifier = "133.37.212.77"
p.authenticationMethod = .none
KeychainWrapper.standard.set("mypassword", forKey: Configuration.KEYCHAIN_PSK_KEY)
let secret = KeychainWrapper.standard.dataRef(forKey: Configuration.KEYCHAIN_PSK_KEY)
p.sharedSecretReference = secret
But when I try to start the connection, nothing happens...
What could be the reason? Why does it run fine with standard iOS OS abilities, but it doesn't from the app?
Thanks!
everyone.
I am trying to override dns resolver settings in my iOS app.
I used NEVPNManager to install a personal vpn and then used onDemandRules to set specific dns servers.
So far my code works for some domains.
Below is my code.
When I put "*.com" in matchDomains, it works perfectly.
But what I want to do is to redirect all dns queries to specific dns server.
I tried empty matchDomains([]) and empty string([""]).
I also tried wildcard expression like ["*"] and ["*.*].
So far I had no success.
It's been a few days and I still can't figure it out.
Can anybody tell me what I am missing here?
Thanks in advance.
let manager = NEVPNManager.sharedManager()
manager.loadFromPreferencesWithCompletionHandler { error in
if let vpnError = error {
print("vpn error in loading preferences : \(vpnError)")
return
}
if manager.protocolConfiguration == nil {
let myIPSec = NEVPNProtocolIPSec()
myIPSec.username = "username"
myIPSec.serverAddress = "server address"
myIPSec.passwordReference = self.getPersistentRef()
myIPSec.authenticationMethod = NEVPNIKEAuthenticationMethod.SharedSecret
myIPSec.sharedSecretReference = self.getPersistentRef()
myIPSec.useExtendedAuthentication = true
manager.protocolConfiguration = myIPSec
manager.localizedDescription = "myDNS"
let evaluationRule = NEEvaluateConnectionRule(matchDomains: ["*.com"], andAction: NEEvaluateConnectionRuleAction.ConnectIfNeeded)
evaluationRule.useDNSServers = ["XXX.XXX.XXX.XXX"]
let onDemandRule = NEOnDemandRuleEvaluateConnection()
onDemandRule.connectionRules = [evaluationRule]
onDemandRule.interfaceTypeMatch = NEOnDemandRuleInterfaceType.Any
manager.onDemandRules = [onDemandRule]
manager.onDemandEnabled = true
manager.enabled = true
manager.saveToPreferencesWithCompletionHandler { error in
if let vpnError = error {
print("vpn error in saving preferences : \(vpnError)")
return
}
}
}
}
I found this is buggy in even the latest iOS (10.3.1) and using NEVPNProtocolIKEv2. One moment it works, the next moment it doesn't want to start a VPN connection because it seems to misinterpret the ondemand rules and gives the error back saying the VPN profile is not enabled. I ended up with configuring the IKEv2 server (Strongswan) to push DNS settings with the "rightdns" option in /etc/ipsec.conf. This gives me the desired result of having the DNS requests redirected to a custom resolver.
I am using www.parse.com for an xcode project. Since they do not allow new sign ups, so how do I get my application id for the following code in order to use their services:
let configuration = ParseClientConfiguration {
$0.applicationId = "YOUR_APP_ID"
$0.server = "http://YOUR_PARSE_SERVER:1337/parse"
}
Parse.initializeWithConfiguration(configuration)
I am trying to get presigned url for these music files from amazon server , I have working code of android but couldn't find a way in Objective-C to do this.
public static String getPreSignedURL(String url) {
java.util.Date expiration = new java.util.Date();
long msec = expiration.getTime();
msec += 1000 * 60 * 5; // 5 minutes
expiration.setTime(msec);
AWSCredentials myCredentials = new BasicAWSCredentials(
AppConstants.AWS_ACCESS_KEY_ID, AppConstants.AWS_SECRET_KEY_ID);
AmazonS3 s3client = new AmazonS3Client(myCredentials);
s3client.setEndpoint(AppConstants.ENDPOINT_S3);
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(
AppConstants.BUCKET_NAME, url.replace(AppConstants.OBJECT_NAME_FILTER, ""));
request.setExpiration(expiration);
URL objectURL = s3client.generatePresignedUrl(request);
return objectURL.toString();
}
This above code is in android.
var presignedUrl: AWSTask = AWSTask()
let expiration = NSDate().dateByAddingTimeInterval(5*60)
let credential = AWSStaticCredentialsProvider.init(accessKey: AWS_ACCESS_KEY_ID, secretKey: AWS_SECRET_KEY_ID)
let configuration = AWSServiceConfiguration.init(region:.USEast1, credentialsProvider: credential)
//print("%#",configuration.endpoint)
//let regionTp = AWSRegionType(s)
AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = configuration
let urlBuilder = AWSS3PreSignedURLBuilder.defaultS3PreSignedURLBuilder()
let preSignedURLRequest = AWSS3GetPreSignedURLRequest.init()
preSignedURLRequest.key = "10488/01-New_Jack_City_hq.mp3"
preSignedURLRequest.bucket = "damixhub"
preSignedURLRequest.expires = expiration
preSignedURLRequest.HTTPMethod = .GET
presignedUrl = urlBuilder.getPreSignedURL(preSignedURLRequest)
This is what I am doing in ios till now but urls have significant difference and I get accessdenied error possibly because I havent mentioned custom end points.
Please let me know if you know solution to this.
I managed to get this using version 1 of amazon sdk.
Just write pod "AWSiOSSDK" if you are using cocoa pods , if you want to do it manually then you need to get it from github get it here
Note - As amazon doesnt provide this functionality in version 2 of sdk I have to use this deprecate version.
I am trying to send push notification from my app ,I have configured everything.After configuration i got cert.pem and key.pem. I have followed this https://blog.engineyard.com/2013/developing-ios-push-notifications-nodejs link . I am able to connect with apple server but not able to send the notification .can anyone help me what can be the issue as i have tried alot but did not get an appropriate solution for my problem. I am using the following code for communicating the apple server
Thanks in advance.
var http = require('http');
var apn = require('apn');
var url = require('url');
var myPhone = "f0e56d999e14ab0504b403efd39b90deb49306045b4ed698e33602abaa862111";
var myDevice = new apn.Device(myPhone);
var note = new apn.Notification();
note.badge = 1;
note.sound = "r.mp3";
note.alert = { "body" : "Your turn!", "action-loc-key" : "Play" , "launch-image" : ""};
note.payload = {'messageFrom': 'Holly'};
note.device = myDevice;
var callback = function(errorNum, notification){
console.log('Error is: %s', errorNum);
console.log("Note " + notification);
}
var options = {
gateway: 'gateway.sandbox.push.apple.com', // this URL is different for Apple's Production Servers and changes when you go to production
errorCallback: callback,
cert: __dirname+'/_certs/cert.pem',
key: __dirname+'/_certs/key.pem',
passphrase: null,
port: 2195,
enhanced: true,
cacheLength: 100
}
var apnsConnection = new apn.Connection(options);
apnsConnection.sendNotification(note);