From 84daff6e3d257d8cf5bfa1ee7556133ec0a743e3 Mon Sep 17 00:00:00 2001
From: Morgan Pretty <morgan.t.pretty@gmail.com>
Date: Tue, 21 Feb 2023 16:05:46 +1100
Subject: [PATCH] Fixed an incorrect push registration

---
 Session/Notifications/SyncPushTokensJob.swift | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/Session/Notifications/SyncPushTokensJob.swift b/Session/Notifications/SyncPushTokensJob.swift
index 4b80934b4..61fb77c80 100644
--- a/Session/Notifications/SyncPushTokensJob.swift
+++ b/Session/Notifications/SyncPushTokensJob.swift
@@ -20,8 +20,11 @@ public enum SyncPushTokensJob: JobExecutor {
         failure: @escaping (Job, Error?, Bool) -> (),
         deferred: @escaping (Job) -> ()
     ) {
-        // Don't run when inactive or not in main app
-        guard (UserDefaults.sharedLokiProject?[.isMainAppActive]).defaulting(to: false) else {
+        // Don't run when inactive or not in main app or if the user doesn't exist yet
+        guard
+            (UserDefaults.sharedLokiProject?[.isMainAppActive]).defaulting(to: false),
+            Identity.userExists()
+        else {
             deferred(job) // Don't need to do anything if it's not the main app
             return
         }