react-native-navigation 1.1.45 and RN 0.43 compatibility - reactjs

I am not able to setting up react-native-navigation for android version. My IOS app is working fine with same version of RNN and RN.
Help me configure for android.
Here is few important file from my app,
MainActivity.java
package com.MY_APP_NAME;
import com.facebook.react.ReactActivity;
import com.oblador.vectoricons.VectorIconsPackage;
import com.reactnativenavigation.bridge.NavigationReactPackage;
public class MainActivity extends ReactActivity {
#Override
protected String getMainComponentName() {
return "ttapp";
}
}
MainApplication.java
package com.MY_APP_NAME;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.oblador.vectoricons.VectorIconsPackage;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
#Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
#Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new VectorIconsPackage()
);
}
};
#Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
#Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
/App/build.gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId 'com.MY_APP_NAME'
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a": 1, "x86": 2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
productFlavors {
}
}
dependencies {
compile project(':react-native-splash-screen')
compile project(':react-native-navigation')
compile project(':react-native-vector-icons')
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.0.3'
compile 'com.facebook.react:react-native:+'
// From node_modules
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
Everything is working fine. App is also successfully builded. But react-native-navigation is not working.

Are you getting a white screen on the android device? It also happen to me (only while you have debugger enabled), but if you switch task you're good to go. Try to check this issue on the repo, maybe you could find your answers.
BTW as stated by Pritish, in the READ.ME the minimum version of RN supported is 0.48, for v2 you need version 0.51

Related

React Native Navigation does not exist

I had to take a break from working on my react native app for a couple of months and when i came back to work on it again i couldn't boot anything up and i am getting a load of React Native Navigation errors...
I dont really know where to start with this, i have made some changes to the java files but nothing seems to get me out of this hole...
the error is below... if anyone knows how to deal with this i would be really greatful
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainActivity.java:3: error: package com.reactnativenavigation does not exist
import com.reactnativenavigation.NavigationActivity;
^
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainActivity.java:5: error: cannot find symbol
public class MainActivity extends NavigationActivity {
^
symbol: class NavigationActivity
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainApplication.java:21: error: package com.reactnativenavigation does not exist
import com.reactnativenavigation.NavigationApplication;
^
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainApplication.java:22: error: package com.reactnativenavigation.react does not exist
import com.reactnativenavigation.react.NavigationReactNativeHost;
^
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainApplication.java:27: error: cannot find symbol
public class MainApplication extends NavigationApplication {
^
symbol: class NavigationApplication
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainApplication.java:29: error: cannot find symbol
new NavigationReactNativeHost(this) {
^
symbol: class NavigationReactNativeHost
location: class MainApplication
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainApplication.java:47: error: method does not override or implement a method from a supertype
#Override
^
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainApplication.java:51: error: method does not override or implement a method from a supertype
#Override
^
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainApplication.java:53: error: cannot find symbol
super.onCreate();
^
symbol: variable super
location: class MainApplication
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainApplication.java:54: error: cannot find symbol
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
^
symbol: method initializeFlipper(MainApplication,ReactInstanceManager)
location: class MainApplication
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
This is from the build.gradle
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 19
compileSdkVersion = 28
targetSdkVersion = 27
supportLibVersion = "28.0.0"
RNNKotlinVersion = "1.3.61" // Or any version above 1.3.x
RNNKotlinStdlib = "kotlin-stdlib-jdk8"
}
repositories {
google()
mavenLocal()
mavenCentral()
jcenter()
maven { url "$rootDir/../node_modules/react-native/android" }
maven { url 'https://maven.google.com' }
// ADD THIS
maven { url "https://www.jitpack.io" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61"
classpath 'com.android.tools.build:gradle:3.6.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
this if from the app build.gradle
dependencies {
implementation project(':#react-native-community_async-storage')
implementation project(':react-native-linear-gradient')
implementation project(':react-native-image-crop-picker')
implementation project(':react-native-vector-icons')
implementation "androidx.appcompat:appcompat:1.0.0"
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:design:27.1.0'
}
This is the mainapp
public class MainApplication extends NavigationApplication {
private final ReactNativeHost mReactNativeHost =
new NavigationReactNativeHost(this) {
#Override
public boolean isDebug() {
return BuildConfig.DEBUG;
}
#Override
protected List<ReactPackage> getPackages() {
#SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages;
}
#Override
protected String getJSMainModuleName() {
return "index";
}
};
#Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
#Override
public void onCreate() {
super.onCreate();
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}
main activigty just looks like this
package com.battlebuddy;
import com.reactnativenavigation.NavigationActivity;
public class MainActivity extends NavigationActivity {
}
If there is anything you can think of that would help a lot

jhipster react remove # to URL

I'm new to the community. I built an e-commercce application with the Jhipster (Java + React Redux) Monolitica. I have the following problem: The application is configured to display a hashtag (#) in the URL for example ... http://localhost:9000/#/. I removed this parameter in React and everything was right. But when I upload the application with Gradle (./gradew) it works, http://localhost:9000/. But if you type directly into the browser http://localhost:9000/home/ I get ERROR 404, Page not found! -----> my application to check the problem (http://www.severobalanceboard.eco.br - OK), (http://www.severobalanceboard.eco.br/historia - ERROR 404)
_
I think this problme by Spring.
Resolved, for remove Hash tag # To URL, using Jhipster and React [Spring + ReactJs]. I use the link of #Gaƫl Marziou told me.
follows the modifications:
==React==
1 - com/mycompany/myapp/src/main/webapp/app/app.tsx
import { BrowserRouter as Router } from 'react-router-dom';
// import { HashRouter as Router } from 'react-router-dom';
2 - com/mycompany/myapp/src/main/webapp/index.html
<!-- <base href="./"/> -->
<base href="/"/>
3 - com/mycompany/myapp/webpack/webpack.prod.js
},
devServer: {
historyApiFallback: true, /*insert this line - only use for develop*/
stats: options.stats,
hot: true,
contentBase: './build/www',
proxy: [{
context: [
...
==JAVA==
4 - com/mycompany/myapp/src/main/java/br/com/MyApp/config/WebConfigurer.java
#Bean
public Html5RouteFilter html5RouteFilter() {
return new Html5RouteFilter();
}
5 - com/mycompany/myapp/src/main/java/br/com/MyApp/web/Html5RouteFilter.java
YOU NEED CREATE THIS FILE
package com.mycompany.myapp.web;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.filter.OncePerRequestFilter;
import javax.servlet.FilterChain;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.regex.Pattern;
/**
* Filter that distinguishes between client routes and server routes when you don't use '#' in client routes.
*/
public class Html5RouteFilter extends OncePerRequestFilter {
private Logger log = LoggerFactory.getLogger(getClass());
// These are the URIs that should be processed server-side
private static final Pattern PATTERN = Pattern.compile("^/((api|content|i18n|management|swagger-ui|swagger-resources)/|error|h2-console|swagger-resources|favicon\\.ico|v2/api-docs).*");
#Override
protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response,
FilterChain filterChain)
throws ServletException, IOException {
if (isServerRoute(request)) {
filterChain.doFilter(request, response);
} else {
RequestDispatcher rd = request.getRequestDispatcher("/");
rd.forward(request, response);
}
}
protected static boolean isServerRoute(HttpServletRequest request) {
if (request.getMethod().equals("GET")) {
String uri = request.getRequestURI();
if (uri.startsWith("/app")) {
return true;
}
return PATTERN.matcher(uri).matches();
}
return true;
}
}
===END==
now be happy

React native cannot read index.android.delta

I have already tried a lot but could not get it fix. Everything was working good before I added react-native-easy-gridview in my packages.json and then I checked out my changes after that I got this.
Here is my build.gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.pilbara_weed_management_mobile"
minSdkVersion 16
targetSdkVersion 22
versionCode 8
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
compile project(':react-native-mauron85-background-geolocation')
compile project(':react-native-background-task')
compile project(':react-native-keep-awake')
compile project(':react-native-background-timer')
compile project(':react-native-image-resizer')
compile project(':react-native-fcm')
compile 'com.google.firebase:firebase-core:10.0.1' //this decides your firebase SDK version
compile project(':react-native-fetch-blob')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile ("com.facebook.react:react-native:0.47.2") { force = true } // From node_modules
compile project(':react-native-smart-splashscreen')
compile project(':react-native-fs')
compile project(':react-native-file-opener')
compile project(':react-native-camera')
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services'
Edit android/app/build.gradle
use this
compile ("com.facebook.react:react-native:0.44.0") { force = true }
and write version of app you use instead of 0.44.0 and delete something like this
compile "com.facebook.react:react-native:+"
or this
compile "com.facebook.react:react-native:0.44.0"
It cause this error for the RN 0.60. You can solve this by following,
npm i jetifier
npx jetify
fixed it for me on RN 0.60.

Problems using Gluon Charm's Alert

I understand that JavaFX's Alert cannot be used yet with mobile apps. But what about the Gluon Charm Alert?
I have defined a Gluon Mobile MultiView FXML project. I've updated the gradle project's dependencies to include charm-2.2.0.jar, so the Gluon Charm Alert class is available. In order to use it, you also need access to javafx.scene.control.Alert.AlertType.
I don't seem to have compile-time access to the above AlertType class.
I'm using NetBeans 8.1 with the most recent Gluon/Gradle plug-in on a Mac with OS X 10.11.14. Is there an additional configuation dependency I must define?
Thanks in advance for any help.
Here is my build.gradle file.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.0.8'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = 'com.capitals.Capitals'
dependencies {
compile 'com.gluonhq:charm:2.2.0'
androidRuntime 'com.gluonhq:charm-android:2.2.0'
iosRuntime 'com.gluonhq:charm-ios:2.2.0'
desktopRuntime 'com.gluonhq:charm-desktop:2.2.0'
}
jfxmobile {
android {
manifest = 'src/android/AndroidManifest.xml'
}
ios {
infoPList = file('src/ios/Default-Info.plist')
forceLinkClasses = [
'com.asgteach.capitals.**.*',
'com.gluonhq.**.*',
'io.datafx.**.*',
'javax.annotations.**.*',
'javax.inject.**.*',
'javax.json.**.*',
'org.glassfish.json.**.*'
]
}
}
You can access JavaFX Alert.AlertType class, without the need of adding any dependency.
Make sure you are using the latest version of the jfxmobile plugin (1.0.8).
This works on desktop and mobile:
import com.gluonhq.charm.glisten.control.Alert;
import com.gluonhq.charm.glisten.control.AppBar;
import com.gluonhq.charm.glisten.mvc.View;
import com.gluonhq.charm.glisten.visual.MaterialDesignIcon;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
public class BasicView extends View {
public BasicView(String name) {
super(name);
Button button = new Button("Show alert");
button.setOnAction(e -> {
Alert alert = new Alert(AlertType.INFORMATION, "This is an Alert!");
alert.showAndWait();
});
setCenter(new StackPane(button));
}
}
If it isn't the case for you, post your build.gradle and any exception you may have.

Appium and iOS Mobile Safari automation, can it be done?

I cannot get any automation working with Appium vs the Safari mobile browser on an iOS emulator. In my Java project, Safari will launch, but the browser will not even navigate to the specified website. Can anyone tell me what I'm doing wrong with my code?
1) Launch the Appium application on my OSX machine. It is configured with the following settings:
IP Address: 127.0.0.1
Port: 4723
Force Device: Checked - iPhone
User Mobile Safari: Checked
(Note: No messages scroll across the Appium application log screen when I run my project. Previously, I got complaints about a missing iOS 6.0 library, but when I duplicated the 6.1 iOS library and then renamed the directory to 6.0, the messages went away.)
2) Launch Eclipse and open Appium Project
3) Right-click on test code and click RunAs Junit
4) The iPhone emulator launches -- iPhone iOS 6.1
5) Mobile Safari launches...and then goes nowhere (should be going to cnn.com). I get no errors.
Can Appium Java projects actually be used for mobile-Safari automation? I don't see any examples of Safari automation in the Appium sample code repo.
What gives?
Thanks,
Larry
------------------Java code below----------------------------------------
Eclipse Juno is being used to run my Java/Appium project. Here is a much simplified listing of the Java JUnit project code (which, when modified accordingly, and used with iWebDriver and the deprecated iPhoneDriver(), works fine):
import org.junit.Before;
import org.junit.After;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
public class AppiumiPhoneWebDriverDemo {
private String baseUrl;
private WebDriver driver;
#Before
public void setup() throws Exception
{
WebDriver driver;
DesiredCapabilities cap = new DesiredCapabilities();
//cap.setCapability("", "");
//cap.setCapability("browsername", "");
//cap.setCapability("os", "iOS 6.1");
cap.setCapability("device", "iPhone Simulator");
cap.setCapability("app", "safari");
driver = new RemoteWebDriver(new URL("http://localhost:4723/wd/hub"), cap);
baseUrl = "http://www.cnn.com";
}
#After
public void tearDown() throws Exception
{
driver.quit();
}
#Test
public void test_searchWorks() throws Exception
{
this.driver.get(baseUrl);
driver.quit();
}
}
You can definitely do this.
See this code
"use strict";
require("./helpers/setup");
var wd = require("wd"),
_ = require('underscore'),
serverConfigs = require('./helpers/appium-servers');
describe("ios safari", function () {
this.timeout(300000);
var driver;
var allPassed = true;
before(function () {
var serverConfig = process.env.SAUCE ?
serverConfigs.sauce : serverConfigs.local;
driver = wd.promiseChainRemote(serverConfig);
require("./helpers/logging").configure(driver);
var desired = _.clone(require("./helpers/caps").ios81);
desired.browserName = 'safari';
if (process.env.SAUCE) {
desired.name = 'ios - safari';
desired.tags = ['sample'];
}
return driver.init(desired);
});
after(function () {
return driver
.quit()
.finally(function () {
if (process.env.SAUCE) {
return driver.sauceJobStatus(allPassed);
}
});
});
afterEach(function () {
allPassed = allPassed && this.currentTest.state === 'passed';
});
it("should get the url", function () {
return driver
.get('https://www.google.com')
.sleep(1000)
.waitForElementByName('q', 5000)
.sendKeys('sauce labs')
.sendKeys(wd.SPECIAL_KEYS.Return)
.sleep(1000)
.title().should.eventually.include('sauce labs');
});
it("should delete cookie passing domain and path", function () {
var complexCookieDelete = function(name, path, domain) {
return function() {
path = path || '|';
return driver.setCookie({name: name, value: '', path: path,
domain: domain, expiry: 0});
};
};
return driver
.get('http://en.wikipedia.org')
.waitForElementByCss('.mediawiki', 5000)
.allCookies() // 'GeoIP' cookie is there
.deleteCookie('GeoIP')
.allCookies() // 'GeoIP' is still there, because it is set on
// the .wikipedia.org domain
.then(complexCookieDelete('GeoIP', '/', '.wikipedia.org'))
.allCookies() // now 'GeoIP' cookie is gone
.sleep(1000);
});
});
Why do you define a second WebDriver in your setUp method ? Remove this second definition to set up the class member driver.
DesiredCapabilities cap = new DesiredCapabilities();
//cap.setCapability("", "");
//cap.setCapability("browsername", "");
//cap.setCapability("os", "iOS 6.1");
cap.setCapability("device", "iPhone Simulator");
cap.setCapability("app", "safari");
should be
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("deviceName", "iPhone Simulator");
cap.setCapability("browsername", "safari");
cap.setCapability("platformVersion", "7.1");
cap.setCapability("platformName", "iOS");
It works for me. hope it fix your issue. Good luck.
Assuming you're using Java on Mac, here's something which works for me, including the code to start Appium Service itself, then the driver to connect to it:
package baseTest;
import com.groupon.tests.mainapp.pages.*;
import io.appium.java_client.ios.IOSDriver;
import io.appium.java_client.service.local.AppiumDriverLocalService;
import io.appium.java_client.service.local.AppiumServiceBuilder;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import java.io.File;
import java.io.IOException;
import java.net.URL;
public class AppiumSafariBaseUITest {
private WebDriver wd;
protected WebDriver getDriver(){
return wd;
}
String nodePath = "/Applications/Appium.app/Contents/Resources/node/bin/node";
String appiumJSPath = "/usr/local/lib/node_modules/appium/build/lib/main.js";
AppiumDriverLocalService service;
String service_url;
private void startAppiumServer() throws IOException {
service = AppiumDriverLocalService.buildService(new AppiumServiceBuilder()
.usingPort(4890)
.usingDriverExecutable(new File(nodePath))
.withAppiumJS(new File(appiumJSPath))
);
service.start();
}
#BeforeClass(alwaysRun = true)
public void setUpAppiumDriver() throws IOException {
startAppiumServer();
service_url = service.getUrl().toString();
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("appium-version", "1.0");
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("platformVersion", "9.3");
capabilities.setCapability("deviceName", "iPhone 5s");
capabilities.setCapability("newCommandTimeout", 600);
capabilities.setCapability("bundleId", "com.apple.mobilesafari");
capabilities.setCapability("useLocationServices", false);
wd = new IOSDriver(new URL(service_url), capabilities);
}
#BeforeMethod(alwaysRun = true)
public void beforeMethod(){
if(!service.isRunning())
{
service.start();
}
}
#AfterClass(alwaysRun = true)
public void killSimulatorAndAppium(){
service.stop();
}
}

Resources