Meteor.loginwithpassword无法在iOS上运行

时间:2021-08-05 16:47:40

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.

我正在为iOS 8.3 +开发Meteor应用程序,而且我在使用帐户密码包在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.

正如您所看到的,我正在验证Drupal用户,该工作正常。应用程序本身也适用于浏览器。我得到的问题是,当我创建本机ios应用程序时,Meteor.loginwithpassword和Accounts.createUser方法停止工作。

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.

出于测试目的,我创建了一个新的meteor应用程序,该应用程序只有{{> loginButtons}}模板并将其部署到iOS。登录显示在模拟器中。它不会出现在设备上。

Here's a full list of the packages I'm using:Meteor.loginwithpassword无法在iOS上运行

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

What am I doing wrong here?

我在这做错了什么?

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

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

2 个解决方案

#1


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:

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

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.com服务器作为临时解决方案,请使用:

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!

希望这有助于某人!

#2


To run it on your local machine (for development), first find your IP (/sbin/ifconfig will help on Linux and OSX).

要在本地计算机上运行它(用于开发),首先要找到你的IP(/ sbin / ifconfig对Linux和OSX有帮助)。

Then just run

然后跑吧

 meteor run  --mobile-server <IP:PORT> <PLATFORM-DEVICE>

In my case my development machine's IP is 192.168.1.66. And meteor runs on default port (3000) on it, so the command is:

在我的情况下,我的开发机器的IP是192.168.1.66。并且meteor在默认端口(3000)上运行,因此命令是:

 meteor run  --mobile-server 192.168.1.66:3000 ios-device

Notes:

  • Without the port, it was not working for me.
  • 没有端口,它对我不起作用。

  • Make sure your phone/mobile-device is in the same network/has access to your development machine (ie: has access to 192.168.1.66 in my case)
  • 确保您的手机/移动设备位于同一网络/可以访问您的开发机器(即:在我的情况下可以访问192.168.1.66)

  • Running 'meteor build ...', was not necessary for me to make this work.
  • 运行'meteor build ...',对我来说没有必要做这项工作。

#1


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:

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

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.com服务器作为临时解决方案,请使用:

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!

希望这有助于某人!

#2


To run it on your local machine (for development), first find your IP (/sbin/ifconfig will help on Linux and OSX).

要在本地计算机上运行它(用于开发),首先要找到你的IP(/ sbin / ifconfig对Linux和OSX有帮助)。

Then just run

然后跑吧

 meteor run  --mobile-server <IP:PORT> <PLATFORM-DEVICE>

In my case my development machine's IP is 192.168.1.66. And meteor runs on default port (3000) on it, so the command is:

在我的情况下,我的开发机器的IP是192.168.1.66。并且meteor在默认端口(3000)上运行,因此命令是:

 meteor run  --mobile-server 192.168.1.66:3000 ios-device

Notes:

  • Without the port, it was not working for me.
  • 没有端口,它对我不起作用。

  • Make sure your phone/mobile-device is in the same network/has access to your development machine (ie: has access to 192.168.1.66 in my case)
  • 确保您的手机/移动设备位于同一网络/可以访问您的开发机器(即:在我的情况下可以访问192.168.1.66)

  • Running 'meteor build ...', was not necessary for me to make this work.
  • 运行'meteor build ...',对我来说没有必要做这项工作。