I believe the verbiage used is that the Constitution applies "wherever the United States has jurisdiction" and it covers everyone, including non-citizens.

In any case, the courts have used Trump's campaign rhetoric and tweets when deciding the case. He said he was going to ban Muslims and then hired Giuliani with the specific purpose to make such a ban appear to not be targeted on Muslims. Since all of that is admissible as evidence, the courts have labeled his ban as violating the 1st Amendment protections. According to a lawyer friend of mine, that's relatively "cut and dried". She's reading the decisions as they're released.

Now the administration is arguing that such statements should not be taken into account. It will be interesting to see my friends take on the arguments presented. 

All of this is entirely predictable when you have a chief executive with little legal background who simply blurts things out on twitter rather than measuring their words carefully.