我正在使用javascript尝试发送包含HTML或附件的电子邮件,但这对于mailto:是不可能的。所以现在我需要一些其他方式来发送HTML或附件与电子邮件。我发现这个电子邮件编辑器插件到phonegap,它应该可以正常工作,但它根本不打开电子邮件应用程序,也不会提示您可以选择电子邮件应用程序的窗口。
public class FragmentMain extends Fragment {
private Bundle savedInstanceState;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
this.savedInstanceState = savedInstanceState;
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
containerView = inflater.inflate(R.layout.fragment_main, container, false);
//mapView bug https://code.google.com/p/gmaps-api-issues/issues/detail?id=6237#c9
final Bundle mapViewSavedInstanceState =
savedInstanceState != null ?
savedInstanceState.getBundle("mapViewSaveState") : null;
vmGoogleMap.create( mapViewSavedInstanceState ;
return containerView;
}
@Override
public void onSaveInstanceState(Bundle outState) {
//mapView bug https://code.google.com/p/gmaps-api-issues/issues/detail?id=6237#c9
final Bundle mapViewSaveState = new Bundle(outState);
vmGoogleMap.onSaveInstanceState(mapViewSaveState);
outState.putBundle("mapViewSaveState", mapViewSaveState);
super.onSaveInstanceState(outState);
}
}
答案 0 :(得分:2)
确保以下内容:
使用命令行导航到项目文件夹并运行以下命令:
cordova插件添加 https://github.com/katzer/cordova-plugin-email-composer.git
大多数Cordova插件无法使用网络浏览器进行测试,并且需要设备或模拟器可用,请确保在设备或模拟器上测试代码。
在chrome或safari上使用远程调试,直接在连接的设备上调试应用程序,看看出了什么问题。
Chrome远程调试: https://developer.chrome.com/devtools/docs/remote-debugging Safari远程调试:http://moduscreate.com/enable-remote-web-inspector-in-ios-6/
修改您的代码以显示isAvailable变量的值,并查看您的测试环境中是否有电子邮件插件。
document.addEventListener('deviceready', function () {
cordova.plugins.email.isAvailable(
function (isAvailable) {
alert("is email mobile available? " + (isAvailable ? "Yes" : "No"));
if(isAvailable){
window.plugin.email.open({
to: 'test@test.com',
subject: 'Greetings',
body: 'How are you? Nice greetings from Leipzig'
}, callback, scope);
}
}
);
}, false);
function callback(){
console.log("callback function");
}
function scope(){
console.log("scope function");
}