managarten/memoro/apps/mobile/features/rating/services/ratingService.ts
Till-JS e7f5f942f3 chore: initial commit - consolidate 4 projects into monorepo
Projects included:
- maerchenzauber (NestJS backend + Expo mobile + SvelteKit web + Astro landing)
- manacore (Expo mobile + SvelteKit web + Astro landing)
- manadeck (NestJS backend + Expo mobile + SvelteKit web)
- memoro (Expo mobile + SvelteKit web + Astro landing)

This commit preserves the current state before monorepo restructuring.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 23:38:24 +01:00

60 lines
No EOL
1.7 KiB
TypeScript

import * as StoreReview from 'expo-store-review';
import { Platform } from 'react-native';
class RatingService {
/**
* Check if the platform supports in-app reviews
*/
async isAvailable(): Promise<boolean> {
try {
return await StoreReview.isAvailableAsync();
} catch (error) {
console.error('Error checking store review availability:', error);
return false;
}
}
/**
* Request a review from the user
* This will show the native review dialog if available
*/
async requestReview(): Promise<boolean> {
try {
const isAvailable = await this.isAvailable();
if (!isAvailable) {
console.log('Store review is not available on this device');
return false;
}
// Request the review
await StoreReview.requestReview();
// We can't know if the user actually submitted a review,
// but we can track that we showed the prompt
return true;
} catch (error) {
console.error('Error requesting store review:', error);
return false;
}
}
/**
* Get the store URL for manual reviews (fallback)
* This can be used when in-app review is not available
*/
getStoreUrl(): string | null {
if (Platform.OS === 'ios') {
// Memoro App Store ID
const appStoreId = '6451258411';
return `https://apps.apple.com/app/id${appStoreId}?action=write-review`;
} else if (Platform.OS === 'android') {
// Memoro Android package name
const packageName = 'com.memo.beta';
return `https://play.google.com/store/apps/details?id=${packageName}`;
}
return null;
}
}
export const ratingService = new RatingService();