ios in-app purchase prompt not displaying - ios

I am using Glassfy in my Ionic Vue app so a user can purchase a product or subscription. I am able to get the products from my Apple Store Connect account and display them in the App through Glassfy.
However when I try to run the purchase function, nothing happens. I don't get any error code or anything.
This is my code:
const sub = ref();
onMounted(async () => {
initGlassfy();
});
const initGlassfy = async () => {
try {
await Glassfy.initialize({
apiKey: "4ba35c9a634d44158ee6713cfffd83ce",
watcherMode: false,
});
getSku();
} catch (error) {
console.log(error);
}
};
const getSku = async () => {
try {
subOne.value = await Glassfy.skuWithId({ identifier: "30Days" });
} catch (e) {
console.log(e);
}
};
const purchase = async () => {
try {
await Glassfy.purchaseSku({ sku: sub.value });
} catch (error) {
console.log(error);
}
};
I am running the app on my iPhone through Xcode. I have also tried deploying it and opening it through Testflight, but with the same result.
I have already added In-app Purchase as a capability in Xcode.
Does anyone know what I am during wrong?

+1
Got the same problem. Neither "transaction" nor the error will be logged in this example.
Tried it with a sandbox tester on my local physical device.
try {
console.log("going to purchase");
const transaction = await Glassfy.purchaseSku({ sku });
console.log("transaction", transaction);
} catch (error) {
console.log(error);
}

Related

react native google sign in - cannot press next, forgot email, or create account

image of simulator
unable to press the forgot email, create account or next button. When I press them there is no action, it stays on that same signin page. help, privacy and terms work.
wrote the function in the googlesignin.tsx file
import React, { Component } from 'react'
import { Button } from 'react-native'
import {
GoogleSignin,
statusCodes,
} from '#react-native-google-signin/google-signin';
export class GoogleSign extends Component {
constructor(props) {
super(props);
this.state = {
userInfo: null,
};
}
render() {
return(
<Button title={'Sign in with Google'} onPress={async () => {
GoogleSignin.configure({
iosClientId: '552669576534-ninopsfqvitpk59v9kt42mn0r2e4o37h.apps.googleusercontent.com',
webClientId: '552669576534-vpmbo9vbodnaeqghnjai6d0fhcl2enhc.apps.googleusercontent.com',
offlineAccess: true,
});
try {
await GoogleSignin.hasPlayServices();
const userInfo = await GoogleSignin.signIn();
this.setState({userInfo});
console.log(userInfo);
} catch (error) {
if (error.code === statusCodes.SIGN_IN_CANCELLED) {
// user cancelled the login flow
} else if (error.code === statusCodes.IN_PROGRESS) {
// operation (e.g. sign in) is in progress already
} else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
// play services not available or outdated
} else {
// some other error happened
}
}
}}/>
);
}
}
I also have added my inverse url to the workspace.
Please refer this doc, you might have missed to configure signIn which is mandatory
import { GoogleSignin } from '#react-native-google-signin/google-signin';
GoogleSignin.configure();

Is there a way to have my service worker intercept fetch requests coming from a client-side SvelteKit load function? (+page.ts)

I'm trying to have a service worker intercept fetch requests coming from a client-side SvelteKit load function. The network requests are being made, but the fetch event is not being triggered.
The fetch request from the load function is going to /api/allTeams, which is cached as reported by chrome devtools, but like I said, it's not getting intercepted. All the function does it fetch the data, and return it in a prop.
Also, every couple minutes I run invalidateAll(), to reload the data, and even those requests aren't being picked up by the SW.
Thanks!
--reese
src/service-worker.js:
import { build, version } from '$service-worker';
self.addEventListener('fetch', function (event) {
console.log("fetch")
event.respondWith(
fetch(event.request).catch(function () {
return caches.match(event.request);
}),
);
});
self.addEventListener('install', async function (event) {
event.waitUntil(
caches.open("ccs-" + version).then(function (cache) {
cache.add("/api/allTeams")
cache.addAll(build)
return;
}),
);
});
src/app.html:
<script>
const registerServiceWorker = async () => {
if ("serviceWorker" in navigator) {
try {
const registration = await navigator.serviceWorker.register("/service-worker.js", {
scope: "*",
});
if (registration.installing) {
console.log("Service worker installing");
} else if (registration.waiting) {
console.log("Service worker installed");
} else if (registration.active) {
console.log("Service worker active");
}
} catch (error) {
console.error(`Registration failed with ${error}`);
}
}
};
registerServiceWorker()
</script>
src/+page.ts:
export async function load(request: Request) {
const searchQuery = new URL(request.url).searchParams.get("q")
const apiUrl = new URL(request.url)
apiUrl.pathname = "/api/allTeams"
const req = await fetch(apiUrl)
const data = await req.json()
return {data, searchQuery};
}

iOS device not receiving push notification from Firebase Cloud Function

I've created an Ionic chat app with firebase cloud functions. The push notifications are working with Android but not ios.
async getIosToken(token: string, userId: string): Promise<void> {
if (!FCM.hasPermission()) {
FCM.requestPushPermission()
.then(async (hasPerm) => {
if (hasPerm) {
const iosToken = await FCM.getAPNSToken();
if (iosToken === token) {
return;
} else {
this.saveToken(iosToken, userId);
}
}
});
} else {
const iosToken = await FCM.getAPNSToken();
if (iosToken === token) {
return;
} else {
this.saveToken(iosToken, userId);
}
}
}
saveToken(token: string, userId: string): void {
this.userSvc.saveTokenToFirestore(token, userId)
.then(() => {
this.storageSvc.setDeviceToken(token);
});
}
The iOS token is being saved to firebase...although it never prompted the user for request permissions.
I console logged the firebase cloud function and I can see the APNs token.
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
admin.initializeApp();
exports.newChatNotification = functions.firestore
.document(`chat/{id}/messages/{doc}`)
.onWrite(async event => {
const message = event.after.data();
let data: any;
let device: any;
const db = admin.firestore();
console.log('message', message);
console.log('db', db);
if (message) { data = message; }
const receivingUserId = data ? data.receivingUserId : '';
const content = data ? data.content : '';
const sendingUserId = data ? data.sendingUserId : '';
console.log('payload', receivingUserId, sendingUserId);
const payload = {
notification: {
title: 'New message',
body: `${content}`,
click_action: 'FCM_PLUGIN_ACTIVITY'
},
data: {
page: 'tabs/travel-buddies',
}
};
console.log('payload2', payload);
const devicesRef = (await db.collection('devices').doc(`${receivingUserId}`).get()).data();
if (devicesRef) { device = devicesRef; }
const token = device ? device.token : '';
console.log('devicesRef', devicesRef, token);
return admin.messaging().sendToDevice(token, payload);
});
Here's the firebase cloud function console
I'm not sure how to troubleshoot why ios is not receiving a push notification because there aren't any errors and I'm getting the APNs token.
I've also tried updating the build system per Google searches online:
Any help would be greatly appreciated.

Returning Values from Cloud Functions for Firebase to iOS app

I'm trying to use the following Cloud Function for Firebase to communicate between Stripe and my iOS App. However, although console.log(customer) prints out a valid customer JSON object, my iOS app receives nil as the result. Am I returning it in the wrong way?
exports.regCustomer = functions.https.onCall((data,context) => {
const email = data.email;
return stripe.customers.create({
email: email,
}, function(err, customer) {
if (err) {
console.log(err);
throw new functions.https.HttpsError('stripe-error', err);
} else {
console.log("customer successfully created");
console.log(customer);
return customer;
}
});
});
You should use the promise mode of the Stripe Node.js library and not the callback mode, see https://github.com/stripe/stripe-node/wiki/Promises
Then, modifying your code along these lines should do the trick:
exports.regCustomer = functions.https.onCall((data, context) => {
const email = data.email;
return stripe.customers.create({
email: email
})
.then(function(customer) {
console.log("customer successfully created");
console.log(customer);
return {customer: customer};
}, function(err) {
throw new functions.https.HttpsError('stripe-error', err);
});
});

Recording voice note is not working on IOS using ionic media plugin

I'm trying to record voice note on ios device using ionic cordova Media and File plugin and pushing it to firebase storage.
On android is working well.
This is my code:
First I created the init() function
init(): Promise < any > {
this.date = moment().format('x');
return new Promise((resolve, reject) => {
let currentFile: File;
this.fileName = this.date + `-rnb.mp3`;
this.file.createFile(this.platform.is('ios') ? cordova.file.tempDirectory : cordova.file.dataDirectory, this.fileName, true).then((result) => {
this.current_file_playing = this.createAudioFile(this.storageDirectory, this.fileName);
resolve();
}, (e) => {
console.log(JSON.stringify(e, null, 2));
reject(e);
})
});
}
this.storageDirectory it's a variable defined in the provider constructor() equal to directory path depends on the platform. and this is the following code:
this.platform.ready().then(() => {
if (this.platform.is('ios')) {
this.storageDirectory = this.file.tempDirectory;
} else if (this.platform.is('android')) {
this.storageDirectory = this.file.externalDataDirectory;
}
});
Then the record() function is listener to record button
record(){
return new Promise((resolve,reject)=>{
this.init().then((media:Media) => {
try {
this.startRecording(media);
resolve(media);
} catch (e) {
console.log(e);
}
});
});
}
This is the startRecording() function:
startRecording(mediaPlugin: any) {
this.current_file_playing.startRecord();
}
Moreover stopRecording() function is a listener to stop button:
stopRecording(mediaPlugin: any) {
return new Promise((resolve,reject)=>{
this.current_file_playing.stopRecord();
this.current_file_playing.play();
this.current_file_playing.setVolume(0.0); //trick
this.saveFirebase().then((downloadUrl) => {
resolve(downloadUrl);
});
});
}
And Finally this is how I'm pushing to firebase, using saveFirebase() function
saveFirebase() {
return new Promise((resolve, reject) => {
let storageRef = firebase.storage().ref();
let metadata = {
contentType: 'audio/mp3',
};
this.file.readAsDataURL(this.storageDirectory, this.fileName).then((file) => {
let voiceRef = storageRef.child(`voices/${this.fileName}`).putString(file, firebase.storage.StringFormat.DATA_URL);
voiceRef.on(firebase.storage.TaskEvent.STATE_CHANGED, (snapshot) => {
console.log("uploading");
}, (e) => {
console.log('inside the error');
reject(e);
console.log(JSON.stringify(e, null, 2),'this.error');
}, () => {
var downloadURL = voiceRef.snapshot.downloadURL;
resolve(downloadURL);
});
});
});
}
Explanation of saveFirebase() function
First I transformed the file to base64 using this.file.readAsDataURL(...) then I pushed the Firebase Storage using putString method.
The audio file is successfully pushed to Firebase Storage, But with 0 Byte size. That is mean to pushing to Firebase is working well, but the recording voice to the file is not working.
The audio files that have size is recorded from android device.
Anyone have an idea what is my problem?
Thanks.
The problem was:
The audio file should be .wav. So when I changed the type of audio to became wav.
let metadata = {
contentType: 'audio/wav',
};
this.fileName = this.date + `-rnb.mp3`;
It work for me.
Thanks.

Resources