fix integration code with pluginPath and improve reliability on IOS by moving script into body