The issue I am facing is that even when I run my app from a physical device, I get
the error "No FCM token found," while push notifications are enabled in my
Xcode capabilities. I don't see the FCM token generated in the users' collection on
Firestore. While the code setup seems good, the same error persists. I have implemented the logic to retrieve the FCM token,
hat the necessary permissions are granted in my app.Here are my Firestore rules:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Allow authenticated users to read and write their own user data
match /users/{userId} {
allow read: if request.auth != null;
allow update: if request.auth != null &&
(request.auth.uid == userId ||
// Allow FCM token updates
request.resource.data.diff(resource.data).affectedKeys().hasOnly(['fcmToken']));
allow create: if request.auth != null;
match /followers/{followerId} {
allow read: if request.auth != null;
allow write: if request.auth != null && request.auth.uid == followerId;
}
match /following/{followingId} {
allow read: if request.auth != null;
allow write: if request.auth != null && request.auth.uid == userId;
}
match /blockedUsers/{blockedUserId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
}
// Messages collection
match /messages/{messageId} {
allow create: if request.auth != null &&
(request.resource.data.senderId == request.auth.uid ||
request.resource.data.receiverId == request.auth.uid);
allow read, update, delete: if request.auth != null &&
(resource.data.senderId == request.auth.uid ||
resource.data.receiverId == request.auth.uid);
}
// Chats collection
match /chats/{chatId} {
allow create: if request.auth != null &&
request.auth.uid in request.resource.data.participants;
allow read, update, delete: if request.auth != null &&
request.auth.uid in resource.data.participants;
}
// Call-related documents
match /calls/{callId} {
allow create: if request.auth != null &&
request.auth.uid in [request.resource.data.callerId, request.resource.data.receiverId];
allow read, write: if request.auth != null &&
(request.auth.uid == resource.data.callerId ||
request.auth.uid == resource.data.receiverId);
}
// Posts
match /posts/{postId} {
allow read: if true;
allow create, update: if request.auth != null;
allow delete: if request.auth != null && request.auth.uid == resource.data.userId;
}
// Reports
match /reports/{reportId} {
allow create: if request.auth != null;
allow read: if request.auth != null;
allow update: if request.auth != null;
}
// ✅ New livestreams collection rule added here
match /livestreams/{document} {
allow read, write: if request.auth != null;
}
}
}
[my index.js](https://developer.apple.com/forums/content/attachment/bffd0276-ece5-4ce9-b08b-83e8770cb8f2)
[My code of class AppDelegate](https://developer.apple.com/forums/content/attachment/abba6a58-d513-49d4-a1d4-dc7dfae56e0a)
[code of class AVDelegateWrapper:](https://developer.apple.com/forums/content/attachment/acd15ac0-ba9e-415f-9503-aea88377e92f)
`
[struct ContentView](https://developer.apple.com/forums/content/attachment/4f75c535-860e-488f-835b-63c76586ac50)
`
[And for after Login code : ](https://developer.apple.com/forums/content/attachment/f6af060e-f2bb-417f-af08-a946dd650474)
`
Topic:
Developer Tools & Services
SubTopic:
Xcode