Using ionic package/native cloud build, mailto works using ion-item but does not work using a button


#1

In showEmailModal() method, the mailto works with ionic package/native cloud build using ion-item. The mailto does not work when using a button. However, when building locally with a MAC/Xcode the mailto works with ion-item and button.

*Note: When click occurs on button, the call to showEmailModal works fine (successfully invokes mailto) when building locally on MAC. The mailto does not work using ionic package/native cloud build.

<button ion-button color="primary" icon-left (click)="showEmailModal(candidate)">       
  ...
</button>

*Note: When click occurs on ion-item, the call to showEmailModal works fine (successfully invokes mailto) when building locally on MAC and when using ionic package/native cloud build.

<ion-item detail-push (click)="showEmailModal(candidate)">
  ...
</ion-item>
showEmailModal(candidate: Candidate) {
    if (candidate.email) {
        window.open('mailto:' + candidate.email + '?subject=Email from ' + this.getRecruiterRankFirstLast());
        let callModal = this.modalCtrl.create(CallModal,
            { candidates: [candidate], type: 'email' });
        callModal.onDidDismiss((data: ContactHistoryAddRequest) => {
            this.logger.trace('got back from modal - ' + data);
            this.getContactHistory(this.candidate);
            if (data) {
                candidate.comment = data.comment;
                candidate.action = data.action;
                candidate.date = data.date;
                candidate.recruiter = this.getRecruiterRankLastFirst();
            }
        });
        setTimeout(function () {
            callModal.present();
        }, 1000);
    } else {
        this.appState.setMessage(Message.lowSeverity('No Email for Candidate'));
    }
}

Cordova CLI: 6.5.0
Ionic Framework Version: 3.0.1
Ionic CLI Version: 2.2.2
Ionic App Lib Version: 2.2.1
Ionic App Scripts Version: 1.3.0
Node Version: v6.10.2


#2

I changed your post to format your code or error message correctly. Please use the </> button above the post input field to format your code or error message or wrap it in ``` (“code fences”) manually. This will make sure your text is readable and if it recognizes the programming language it also automatically adds code syntax highlighting. Thanks.


#3

Ok, to make sure that I understood correctly:

You have a project with platform ios. In there you have a button and an ion-item, both calling the same function on click When you build it using Ionic Package, the button does not work. When you build it locally using XCode, both work.

Any Cordova plugins involved in the code in any way?


#4

Yes. You understand the situation perfectly. No Cordova plugins are involved in the code in any way. Thanks.


#5

That is strange.

Can you show us the command you use to build with Ionic Package?
Did you debug the app on the device to see if there are any errors in the Webview console?


#6

Below is the command. We also tried changing prep-cloud build to ‘ionic build ios’, instead of ‘ionic build browser’ but yielded same result. We did debug the device and saw no errors.

npm run ios:cloud:dev

"update-build-number": {
  "command": "node config/update-build-number.js"
},
"prep-cloud-build": {
  "command": "bnr update-build-number && ionic build browser"
},
"ios:cloud:dev": {
  "command": "bnr prep-cloud-build && ionic package build ios --profile etav_dev",
  "env": {
    "NODE_ENV": "development",
    "PLATFORM": "ios"
  }
},

#7

Okay so you are on a Mac? Can you try ionic run ios or ionic emulate ios to see if it works then?


#8

I have performed a local build (ionic run ios) on my Mac multiple times. When doing so mailto works in the showEmailModal() when a click occurs on the ion-item and when a click occurs a button. However, when building with ionic package/native cloud build (ionic package build ios) clicking on ion-item works, but clicking on a button does not.


#9

Ok strange, then my theory is probably wrong:
ionic package uploads whatever is in /www at the moment of execution, and I thought maybe ionic build browser was different enough from the normal iOS build for it to cause trouble.

Another idea: Replace ionic build browser in you prep-cloud-build with npm run build.


#10

I replaced “ionic build browser in our prep-cloud-build with npm run build” and it did not work.

Assuming the local build (ionic run ios) on my Mac uses the same WWW folder that ionic package/native cloud build (ionic package build ios) uses … could we be missing a configuration item related issue to the ionic package/native cloud build.


#11

To explore the possibility of a configuration difference with the cloud build, I compared the cloud build IPA file to the local Mac build IPA file. One difference I found was in the cordova.js file. The cordova.js file in the cloud build IPA file contained PLATFORM_VERSION_BUILD_LABEL = ‘4.2.1’ whereas the local Mac build IPA file contained PLATFORM_VERSION_BUILD_LABEL = ‘4.3.1’ in its cordova.js file. We have the following specified in the config.xml file … engine name=“ios” spec="~4.3.1".

Two questions:

  1. Why the difference in the Cordova versions and could this possibly be the root of the problem?

  2. What version of Xcode is running in the background for the Ionic Package/Cloud Native build? I’m running version 8.3.2 locally on my Mac.


#12

Why? No idea.
You can find out if this is caused by this version by installing this version locally and building with this one.


#13

Building locally with Cordova 4.2.1 was the first thing I tried after I discovered the different versions; however, I cannot get the IPA file to build with Cordova 4.2.1. With Cordova 4.3.1, it builds fine. I will have to investigate further why the IPA will not build with Cordova 4.2.1.

Can you tell me which version of Xcode is running in the background for the Ionic Package/Cloud Native build? I’m running version 8.3.2 locally on my Mac?


#14

No idea, sorry. You would have to ask someone from Ionic about this: https://ionic.zendesk.com/hc/en-us/requests/new?ticket_form_id=632068


#15

Per your suggestion, I opened a ticket with Ionic primary support. They upgraded Ionic Package. I performed a cloud build using Package and now the Cordova iOS version is 4.3.1 in the cloud built IPA file, which now matches our local build IPA version. It also fixed the issue we were having in our app regarding the same function call on click working with ion-item, but not working with button click.