I create a service worker and a payment manager they are well registered on my browser. I made an instrument set but I can't find the instrument to register with the payment methods and when I look at the payment process, the instrument key is empty.
console.log(navigator.serviceWorker.ready)
return navigator.serviceWorker.ready;
}).then((registration) => {
console.log(registration)
if (!registration.paymentManager) {
console.log('No payment handler capability in this browser. Is chrome://flags/#service-worker-payment-apps enabled?');
return;
}
if (!registration.paymentManager.instruments) {
console.log('Payment handler is not fully implemented. Cannot set the instruments.');
return;
}
registration.paymentManager.instruments
.set('instrument-key', {
name: 'Chrome uses name and icon from the web app manifest',
enabledMethods: ['https://paymentTrequest.fr'],
method: 'https://paymentTrequest.fr',
capabilities: {supportedNetworks: ['yo', 'rt'],
supportedTypes: ['debit', 'credit']}
}) ```
[![image handlers payment navigator][1]][1]
[1]: https://i.stack.imgur.com/73RA2.png
Related
My code is set up as follows:
export class HomePage implements OnInit {
ngOnInit() {
console.log('Initializing HomePage');
// Request permission to use push notifications
// iOS will prompt user and return if they granted permission or not
// Android will just grant without prompting
PushNotifications.requestPermission().then( result => {
if (result.granted) {
// Register with Apple / Google to receive push via APNS/FCM
PushNotifications.register();
} else {
// Show some error
}
});
// On success, we should be able to receive notifications
PushNotifications.addListener('registration',
(token: PushNotificationToken) => {
alert('Push registration success, token: ' + token.value);
}
);
// Some issue with our setup and push will not work
PushNotifications.addListener('registrationError',
(error: any) => {
alert('Error on registration: ' + JSON.stringify(error));
}
);
// Show us the notification payload if the app is open on our device
PushNotifications.addListener('pushNotificationReceived',
(notification: PushNotification) => {
alert('Push received: ' + JSON.stringify(notification));
}
);
// Method called when tapping on a notification
PushNotifications.addListener('pushNotificationActionPerformed',
(notification: PushNotificationActionPerformed) => {
alert('Push action performed: ' + JSON.stringify(notification));
}
);
}
If the user denies permission on app first launch and then goes into the settings app and enables push notifications and then comes back to the app (without restarting the app) how do I access the registered token in this case? Do I need to register the token each time the app comes into the foreground as well as on app start? What is the recommended approach for an Ionic Capacitor app? Thanks!
I use platform.resume to test scenarios like this. You'll need capacitor3 for this as this was broken in capacitor2.
I'm implementing apple-authentication in react native using expo-apple-authentication package.
Below is the code which I'm calling on button's onPress.
async handleSocialLogin() {
const { mutate, BB, onSuccess, navigation } = this.props;
try {
const result = await AppleAuthentication.signInAsync({
requestedScopes: [
AppleAuthentication.AppleAuthenticationScope.FULL_NAME,
AppleAuthentication.AppleAuthenticationScope.EMAIL,
],
});
Alert.alert(JSON.stringify(result))
// signed in
} catch (e) {
Alert.alert(e)
if (e.code === 'ERR_CANCELED') {
// handle that the user canceled the sign-in flow
} else {
// handle other errors
}
}
}
It should return me authentication-token, Full_Name and Email which I requested in scope but It is giving me null for Full_Name and Email.
As per the documentation:
requestedScopes (AppleAuthenticationScope[]) (optional) - Array of user information scopes to which your app is requesting access. Note that the user can choose to deny your app access to any scope at the time of logging in. You will still need to handle null values for any scopes you request. Additionally, note that the requested scopes will only be provided to you the first time each user signs into your app; in subsequent requests they will be null.
You have probably already logged in once and didn't catch the logs. Subsequent log in will result in this data being null
I am trying to redirect on specific page after click on notification from tray in react-native-fcm, but unable to do so. React native fcm documentation does not have proper documentation on handling click listener
I follow this tutorial for react-native-fcm
this.notificationListener = FCM.on(FCMEvent.Notification, notif => {
console.log("Notification recived", notif);
if(notif.local_notification){
console.log("Notification recived local", "local notification");
return;
}
if(notif.opened_from_tray){
console.log("Notification recived tray ", "opened from tray");
return;
}
if(Platform.OS ==='ios'){
//optional
//iOS requires developers to call completionHandler to end notification process. If you do not call it your background remote notifications could be throttled, to read more about it see the above documentation link.
//This library handles it for you automatically with default behavior (for remote notification, finish with NoData; for WillPresent, finish depend on "show_in_foreground"). However if you want to return different result, follow the following code to override
//notif._notificationType is available for iOS platfrom
switch(notif._notificationType){
case NotificationType.Remote:
notif.finish(RemoteNotificationResult.NewData) //other types available: RemoteNotificationResult.NewData, RemoteNotificationResult.ResultFailed
break;
case NotificationType.NotificationResponse:
notif.finish();
break;
case NotificationType.WillPresent:
notif.finish(WillPresentNotificationResult.All) //other types available: WillPresentNotificationResult.None
break;
}
}
Any help would be appreciated.
Thanks in advance
hi everyone problem are fixed by using the setTimeout function in notification opened_from_tray block.
Sample Code
redirect(){ this.props.navigator.push({name:"DetailPage", data:this.state.pageData[1]}); }
`
this.notificationListener = FCM.on(FCMEvent.Notification, notif => {
console.log("Notification recived", notif);
if(notif.local_notification){
console.log("Notification recived local", "local notification");
if(notif.opened_from_tray){
console.log("Notification recived local ", "opened from tray");
setTimeout(() => {
// console.log('setting page call!');
console.log('this is props',props);
this.redirect()
// this.props.navigator.push({name:"Sports"});
// // this.props.navigator.push({name:'DetailPage',data:Data});
}, 5000);
//this.props.navigator.push({name:"Settings"});
}
return;
}
if(notif.opened_from_tray){
console.log("Notification recived tray ", "opened from tray");
//this.props.navigator.replacePrevious({name:"Settings"});
return;
}
if(Platform.OS ==='ios'){
//optional
//iOS requires developers to call completionHandler to end notification process. If you do not call it your background remote notifications could be throttled, to read more about it see the above documentation link.
//This library handles it for you automatically with default behavior (for remote notification, finish with NoData; for WillPresent, finish depend on "show_in_foreground"). However if you want to return different result, follow the following code to override
//notif._notificationType is available for iOS platfrom
switch(notif._notificationType){
case NotificationType.Remote:
notif.finish(RemoteNotificationResult.NewData) //other types available: RemoteNotificationResult.NewData, RemoteNotificationResult.ResultFailed
break;
case NotificationType.NotificationResponse:
notif.finish();
break;
case NotificationType.WillPresent:
notif.finish(WillPresentNotificationResult.All) //other types available: WillPresentNotificationResult.None
break;
}
}`
We are using Twilio in our application for voice communication.
When making voice call, we are setting up Twilio device as below.
If call is not successful, we are retrying few more time calling below function again.
My question is doesn't destroy function delete the event handlers as well? And why do I see in log "[Device] Found existing Device; using new token but ignoring options" when I call setup after calling destroy?
function setupTwilio(token) {
if (angular.isFunction(Twilio.Device.destroy)) {
console.log('Destroying Twilio device');
Twilio.Device.destroy(); // Destroy before setup incase we have already run this
}
startEventHandlers(); // add event handlers for Twilio events e.g. connect, disconnect
trySetup = function () {
var params = { debug: ( DEBUG ? true : false ) };
if (DEBUG) {
console.log('trying the twilio setup at ' + new Date());
console.log(Twilio.Device.instance);
}
// Twilio will not hit the handlers specified in startEventHandlers until a successful setup has been created, so run try catch here
try {
Twilio.Device.setup(token, params);
} catch (e) {
if (DEBUG) {
console.log('TwilioSetup uncaught error: ' + e);
}
}
};
if (angular.isDefined(token)) {
trySetup();
}
}
Destroy will trigger the offline event handler. Try setting up the device inside the offline event handler:
Twilio.Device.offline(function() {
Twilio.Device.setup(token, params);
});
When i run fb.login() in an ios 6 device using the account setted in Settings/facebook i get the following
operation couldn't be completed (com.facebook.sdk error 2)
in ios 5 the app works perfectly, the problem is the native login
help please ! this is my code
this is the facebook init
this.appId = appId;
var me = this;
document.addEventListener('deviceready', function() {
try {
FB.init({ appId: "294003447379425", status: true, cookie: true, nativeInterface: CDV.FB, useCachedDialogs: false });
} catch (e) {
console.log(e);
}
}, false);
if (!this.appId) {
Ext.Logger.error('No Facebook Application ID set.');
return;
}
var me = this;
me.hasCheckedStatus = false;
FB.Event.subscribe('auth.logout', function() {
// This event can be fired as soon as the page loads which may cause undesired behaviour, so we wait
// until after we've specifically checked the login status.
if (me.hasCheckedStatus) {
me.fireEvent('logout');
}
});
// Get the user login status from Facebook.
FB.getLoginStatus(function(response) {
me.fireEvent('loginStatus');
clearTimeout(me.fbLoginTimeout);
me.hasCheckedStatus = true;
if (response.status == 'connected') {
me.fireEvent('connected');
Ext.Viewport.add(Ext.create('CinePass.view.Main'));
} else {
me.fireEvent('unauthorized');
console.log('noconectado');
Ext.Viewport.add(Ext.create('CinePass.view.LoggedOut'));
}
});
// We set a timeout in case there is no response from the Facebook `init` method. This often happens if the
// Facebook application is incorrectly configured (for example if the browser URL does not match the one
// configured on the Facebook app.)
me.fbLoginTimeout = setTimeout(function() {
me.fireEvent('loginStatus');
me.fireEvent('exception', {
type: 'timeout',
msg: 'The request to Facebook timed out.'
});
Ext.Msg.alert('CinePass', 'Existe un problema con Facebook, se iniciará la aplicación sin conexión a Facebook.', Ext.emptyFn);
Ext.Viewport.add(Ext.create('CinePass.view.Main'));
}, me.fbTimeout);
this is the login
FB.login(
function(response) {
if (response.session) {
alert(response.session);
} else {
alert(response.session);
}
},
{ scope: "email,user_about_me,user_activities,user_birthday,user_hometown,user_interests,user_likes,user_location,friends_interests" }
);
Having the same problem and took me few days to figure this out, there are a number of reasons:
1) The first time you launch your app, if you deny the "Do you allow this app to use your facebook permission", you'll get this error, what you need to do is, go to Setting > General > Facebook > turn on your app OR go to Setting > General > Reset > Reset Location & Privacy (this will reset and ask you the "Do you allow this app to use your facebook permission" again for all app.
2) Slow/No Internet can caused the error
3) Create your certificate again, and go to build.phonegap.com, create a new key for IOS and change the IOS key (This works for me, I have no idea how it works but it does, I notice a significant app file size increase after i use a new IOS Key)
4) If your app is in sand box mode, and your IOS current Facebook account is not an app tester you'll get the error too. I just disable the sand box mode and it works, make sure your Facebook App Setting has the correct bundle ID, if your app is still under developement, put 0 to app store ID.