How to swipe an iOS app page using java?

  1. I want to swipe an iOS app photo gallery section.

  2. I have tried with below coding for swiping an android app photo gallery section, swipe action happened for me in local android device.

  3. The same code doesn’t work in android emulator.

  4. I have tried with same coding in iOS simulator, the swipe action doesn’t happens for me.

    // swipe left
    public void swipeLeft()
    {
    AppiumDriver appiumDriver = (AppiumDriver) driver;
    appiumDriver.context(“NATIVE_APP”);
    Dimension size = appiumDriver.manage().window().getSize();
    int startx = (int) (size.width * 0.8);
    int endx = (int) (size.width * 0.20);
    int starty = size.height / 2;
    appiumDriver.swipe(startx, starty, endx, starty, 1000);

    }

    // swipe right
    public void swipeRight()
    {
    AppiumDriver appiumDriver = (AppiumDriver) driver;
    appiumDriver.context(“NATIVE_APP”);
    Dimension size = appiumDriver.manage().window().getSize();
    int endx= (int) (size.width * 0.8);
    int startx = (int) (size.width * 0.20);
    int starty = size.height / 2;
    appiumDriver.swipe(startx, starty, endx, starty, 1000);

    }