I am running a Meteor app on both browsers and mobile phones. What I want to do is to update the Accounts.urls.verifyEmail accordingly, so the web app opens if the user registered from the web app, and the mobile app gets launched if the user registered from the mobile app.
This is how I am trying to :
Accounts.urls.verifyEmail = function(token) {
if (Meteor.isCordova) {
return 'lybe://email_verification/' + token;
}
else {
return Meteor.absoluteUrl('email_verification/' + token);
}
};
However, even when registering from the mobile app, Meteor.isCordova returns false.
How can I differentiate on the server from Web and Mobile app?
Meteor.isCordova seems to return true on the client side only.
Any suggestion is most welcome
Accounts.urls.verifyEmail is called from server then you cannot use Meteor.isCordova. I think you can checking in email_verification page if client is ios or android or browser and redirect to correct user.
Or you can modify Accounts package and sending client type (ios, android, browser..) when user register
Related
I recently started to receive some reports from users that this stopped working recently, but only on mobile. I've been able to reproduce it with the demo cat application by changing the onGmailInsertCat to
function onGmailInsertCat(e) {
return CardService.newActionResponseBuilder()
.setNotification(CardService.newNotification()
.setText("notificationText")
.setType(CardService.NotificationType.INFO))
.build(); // Don't forget to build the response!
}
On desktop this shows a notification but on mobile nothing happens. I've seen similar results when I return a new card instead. Is there still a way to return a new card on mobile/iOS gmail?
I'm building an app using Angular 6 and Cordova 8.
I need to authenticate my users with the server so I made an interceptor to add on every requests I send the parameter withCredential set to true.
#Injectable()
export class AddCredentialsInterceptor implements HttpInterceptor {
constructor() {
}
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
request = request.clone({
withCredentials: true
});
return next.handle(request);
}
}
It's working fine on web browsers and Android.
However, on IOS, every time I relaunch the application, the PHPSESSID is reset and my user is logged out.
Is there a way to persist it after app relaunch ? Maybe setting an expiry date ?
Thanks !
The solution was indeed to set an expiry date to the cookie on the server side.
Then, the PHPSESSID is not reset at every app relaunch and can be persisted for a certain time.
I've just started testing Firebase for website push notifications. The basic code seems to work perfectly well on many Android-based browsers (Chrome, Firefox...) apps but not those installed on iOS such Chrome on my iPad or iPhone. I couldn't find any information related to this issue. Am I missing something?
firebase.initializeApp(config);
const messaging = firebase.messaging();
messaging.requestPermission()
.then(function () {
console.log('Notification permission granted.');
// TODO(developer): Retrieve an Instance ID token for use with FCM.
// ...
})
.catch(function (err) {
console.log('Unable to get permission to notify.', err);
});
Chrome on iOS is built on top of the same basic web view as Safari. Since that underlying component doesn't support Web Push, FCM push notifications cannot be delivered to Chrome on iOS.
For future reference, if you get a blank page on your website on iOS browsers.
just wrap your server worker in an if statement by checking if FCM is supported in that browser firebase.messaging.isSupported()
if (firebase.messaging.isSupported()) {
firebase.initializeApp({
'messagingSenderId': 'your code here'
});
...
}
I currently have an ionic app, which uses the following plugin: https://github.com/jeduan/cordova-plugin-facebook4 so that users can login to my app using the Facebook SDK, and so that I can track certain custom events, using the logEvent method.
Since it is an ionic app, I have a iOS and an Android build of the app. The custom events are working as expected on the Android platform. The strange thing is that in iOS, when an event is fired, I can clearly see the success event handler being called, indicating success, however, going to the Facebook analytics, I can clearly see that no custom event data is being saved. It tracks the usual app opens etc, it's just that custom events don't seem to be getting recorded for iOS.
Just to be clear any of this logging happens after the user has already logged in, I have heard it only works for iOS if you are authenticated with FB first.
So I have a generic function first:
$scope.fbLogEvent = function(eventName, params, valueToSum) {
if (valueToSum == null) {
valueToSum = 1;
}
if (!ionic.Platform.is('browser')) {
return facebookConnectPlugin.logEvent(eventName, params, valueToSum, function(success) {
return console.info('FB', eventName, 'event has been logged');
}, function(error) {
return console.error(error);
});
}
};
I then call the following function to do the actual tracking
$scope.fbLogEvent('item-requested', { item: $scope.item });
It works perfectly on Android
When I add an item on iOS (using Safari developer logging on the app running on my phone), I can see that the success function is called, because it logs the following message: FB item-requested event has been logged.
I have tested this with the latest version of the plugin (just to be sure), but that did not seem to make a difference.
UPDATE 3/3/2017 - for what it's worth, it does seem to pickup these events if they predefined events, as opposed to custom events.
Scenario:
I want to call the logout function if the app is terminated. I'm able to do it using native code:
- (void)applicationWillTerminate:(UIApplication *)app
{
// Run Logout function
}
Problem:
How to do it in IBM mobilefirst hybrid app?
// ************************************************
Edited
First of all, user login in to the app, if the user key in the correct user id and password, it will add the userIdentity into "loginRealm".
WL.Server.setActiveUser("loginRealm", userIdentity);
Next, user closes the apps without logout. So, when the user login for the another time, MFP server will not return any feedback since it will hit this exception:
Cannot change identity of an already logged in user in realm
'loginRealm'. The application must logout first.
Hence, I have to logout the user from MFP server by setting the "loginRealm" to null in adapter;
WL.Server.setActiveUser("loginRealm", null);
The above line of code is in the logout function defined in authentication-config.xml.
The client side device runs this line of code and it will trigger the logout function. Besides, it will reload the App upon success:
WL.Client.logout('loginRealm', {
onSuccess: WL.Client.reloadApp
});
Steps that I've tried:
1) At WlcommonInit() I added WL.Client.updateUserInfo(); and if WL.Client.isUserAuthenticated("loginRealm") return true I will logout the user from server. However, WL.Client.isUserAuthenticated("loginRealm") will always return false. This is because, it needs to take sometime around (30seconds to 2 minutes) for the flag to turn true after WL.Client.updateUserInfo();. So my login still fail and hit the same error.
2) I tried to logout the users during the user click login button. But the app will refresh and return to login page again due to reloadApp. The logout code I get from IBM mobilefirst website. So user need to click and type 2 times in order to login into the main menu.
WL.Client.logout('loginRealm', {
onSuccess: WL.Client.reloadApp
});
Am I doing it wrongly? Or are there any other methods to get WL.Client.isUserAuthenticated("loginRealm") return true instantly after WL.Client.updateUserInfo(); ? Can we remove the reload app line of code in logout function?
I don't think this is doable, because that logout function (in MFP) will require server connectivity (request and response) and if the app is by then killed, I think it's going to cause unpredictable results.
Note though that it seems to be not recommended to use that function anyway? applicationWillTerminate when is it called and when not
What you should do perhaps in order to simulate it, is to logout-on-login, so that it would appear that the app is logged out when opening it. You can extend the duration of the splash screen so that the end-user will not see that s/he is logged in (in case the session was still alive between the closing and re-opening of the app), until really logged out and then you can display the login screen again or any other required screen.