Meteor.loginwithpassword无法在iOS上运行 [英] Meteor.loginwithpassword not working on iOS

查看:154
本文介绍了Meteor.loginwithpassword无法在iOS上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发适用于iOS 8.3 +的Meteor应用程序,而且我在使用帐户密码包在iOS上运行时遇到了问题。



我的登录代码为:

  Template.login .events({
submit#login-form:function()
{
$ .ajax({
url:http://www.drupalsite.com/ api / v1 / user / login.json,
类型:POST,
dataType:json,
data:$(#login-form)。serializeArray() ,
错误:函数(数据)
{
alert(data.responseJSON [0]);
},
成功:函数(Drupal)
{
alert(正在检查用户......);
Accounts.createUser({
用户名:$(#username)。val(),
密码: $(#password)。val(),
电子邮件:Drupal.mail,
个人资料:
{
uid:Drupal.uid,
名称:Drupal .user.field_first_name.und [0] .safe_value ++ Drupal.user.field_last_name.und [0] .safe_value
}

},函数(错误,结果){

if(error)
{

Meteor.loginWithPassword($( #username)。val(),$(#password)。val());
alert(用户已登录);
$('。login')。animate({
},0,function(){
$('。sign-in')。removeClass('open');
$('。login')。removeClass('open');

});

}其他
{
alert(用户创建);
}

});

}
});

返回false;
}

});



正如你所看到我正在验证一个Drupal用户,它运行正常。应用程序本身也适用于浏览器。我得到的问题是,当我创建本机ios应用程序时, Meteor.loginwithpassword Accounts.createUser 方法停止为了测试目的,我创建了一个只有 {{> loginButtons}} 模板并将其部署到iOS。登录显示在模拟器中。它没有显示在设备上。



这是我正在使用的软件包的完整列表:



我在这里做错了什么?



顺便说一句,请告诉我,无论如何我都可以改进我的问题。

解决方案

如果您在移动项目中使用帐户包,则必须有一台服务器供您的移动设备呼叫。



虽然您可以按原样使用帐户包在您的本地计算机上(Be it Browser或Simulator)在您的移动设备的命令行中使用它:

  meteor build~ / .meteor / local --server = http:// {{your server here}}。com 

然后执行此操作:

  meteor run ios-device --mobile-server http:// {{your server here}}。 com 

确保您的构建已配置正确。



如果没有服务器而不是使用以下方法将应用程序部署到meteor.com服务器作为临时解决方案:

  meteor deploy{{your-app-name-here}}。meteor.com

这里要小心。很多流星开发者正在测试,所以你想尝试使名称尽可能独特。



希望这有助于某人!


I'm working on a Meteor app for iOS 8.3 + and I'm having issues getting the accounts-password package to work on iOS.

I have this code for my login:

Template.login.events({
"submit #login-form": function()
{
    $.ajax({
        url: "http://www.drupalsite.com/api/v1/user/login.json",
        type: "POST",
        dataType: "json",
        data: $("#login-form").serializeArray(),
        error: function(data)
        {
            alert(data.responseJSON[0]);
        },
        success: function(Drupal)
        {
            alert("User being checked...");
            Accounts.createUser({
                username: $("#username").val(),
                password: $("#password").val(),
                email: Drupal.mail,
                profile: 
                    {
                        uid: Drupal.uid,
                        name: Drupal.user.field_first_name.und[0].safe_value + " "+ Drupal.user.field_last_name.und[0].safe_value
                    }

            }, function(error, result){

                if(error)
                {

                    Meteor.loginWithPassword($("#username").val(), $("#password").val());
                    alert("User Logged In");
                    $('.login').animate({
            }, 0, function() {
                $('.sign-in').removeClass('open');
                $('.login').removeClass('open');

            });

                } else
                {
                    alert("User Created");
                }

            });

        }
    });

    return false;
}

});

As you can see I'm validating a Drupal user, which works fine. The application itself works on the browser fine as well. The issue I get is that when I create the native ios app, the Meteor.loginwithpassword and Accounts.createUser methods stop working.

For testing purposes, I created a new meteor app that only had the {{> loginButtons}} template in and deployed it to iOS. The sign in shows up in the simulator. It does not show up on the device.

Here's a full list of the packages I'm using:

What am I doing wrong here?

BTW, please let me know if there's anyway at all I can improve my question.

解决方案

If you are using the Accounts package in your mobile project you must have a server for your mobile device to call on.

While you can use the accounts package as is on your local machine (Be it Browser or Simulator) use this in the command line for your mobile device:

meteor build ~/.meteor/local --server=http://{{your server here}}.com

Afterwards do this:

meteor run ios-device --mobile-server http://{{your server here}}.com

To be sure your build is configured correctly.

If you don't have a server than deploy your app to the meteor.com servers as a temporary solution using:

meteor deploy "{{your-app-name-here}}.meteor.com"

Be careful here. A lot of meteor dev are testing so you want to try and make the name as unique as possible.

Hope this helps someone!

这篇关于Meteor.loginwithpassword无法在iOS上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆