# PushNotification crucial problem 

**URL:** <https://forums.fusetools.com/t/pushnotification-crucial-problem/2222>\
**Category:** Bug Reports\
**Created:** [October 19, 2017, 12:02am UTC](https://forums.fusetools.com/t/pushnotification-crucial-problem/2222 "2017-10-19T00:02:24Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahmed\_Diab](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/ahmed_diab/32/692_2.png) [@Ahmed\_Diab](https://forums.fusetools.com/u/Ahmed_Diab)\
**Post date:** [October 19, 2017, 12:02am UTC](https://forums.fusetools.com/t/pushnotification-crucial-problem/2222/1 "2017-10-19T00:02:24Z")

</div>

Dear Sirs,

We have a crucial problem with `PushNotification` module on Both `Android` and `iOS` and the problem is :  
When the registration got succeeded the `Event Emitter` is not fired neither on Success nor on Failure ! and i have investigated the problem and modified some lines to find out the problem and it was as the following:

```auto
new AsyncTask<Void, Void, String>() {
	@Override protected String doInBackground(Void... params) {
		debug_log("START Requesting the RegID");
		String msg = "";
		try {
			String _regID = gcm.register(senderID);
			debug_log("RegID is success");
			@{getRegistrationIdSuccess(string):Call(_regID)};
			return "Device registered, registration ID=" + _regID;
		} catch (java.io.IOException ex) {
			debug_log("RegID is failed");
			debug_log(ex.getMessage());
			msg = "Error :" + ex.getMessage();
			@{getRegistrationIdError(string):Call(msg)};
			return msg;
		}
	}
	@Override protected void onPostExecute(String msg) {}
}.execute();

```

This problem was visible at many apps i have developed, in some apps only in the `MainView.ux` give me a callback and the rest sometime yes and the most is not !

So, please figure out the problem and have a hotfix soon.

PS: i’m using Cloned version of `Fuselibs` from the master branch.

Best,  
Ahmad

---

<div class="post-metadata">

**Author:** ![Ahmed\_Diab](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/ahmed_diab/32/692_2.png) [@Ahmed\_Diab](https://forums.fusetools.com/u/Ahmed_Diab)\
**Post date:** [October 19, 2017, 12:07am UTC](https://forums.fusetools.com/t/pushnotification-crucial-problem/2222/2 "2017-10-19T00:07:08Z")

</div>

And here is the screenshot from my device log, you will see the

REG ID PROVE --\> this line is printed out from the Impl.uno file inside the following method :

```auto
		static void getRegistrationIdSuccess(string regid)
		{
			debug_log("REG ID Prove : "+regid);
			var x = RegistrationSucceeded;
			if (x!=null)
				x(null, regid);
		}

```

 ![file](https://s3.us-east-2.amazonaws.com/fuse-legacy-forum-assets/q1YWWPQwrC52-image-1508371500050.png)

---

<div class="post-metadata">

**Author:** ![Uldis](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/uldis/32/657_2.png) [@Uldis](https://forums.fusetools.com/u/Uldis)\
**Post date:** [October 19, 2017, 12:00pm UTC](https://forums.fusetools.com/t/pushnotification-crucial-problem/2222/3 "2017-10-19T12:00:29Z")

</div>

Sorry, but it is not clear what the issue is.

The log statement you have added is being executed. So the callback to `getRegistrationIdSuccess` was raised, but you’re saying it was not.

There is nothing we can do until you provide a complete reproduction and a clear description of the problem.

---

<div class="post-metadata">

**Author:** ![Ahmed\_Diab](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/ahmed_diab/32/692_2.png) [@Ahmed\_Diab](https://forums.fusetools.com/u/Ahmed_Diab)\
**Post date:** [October 19, 2017, 12:33pm UTC](https://forums.fusetools.com/t/pushnotification-crucial-problem/2222/4 "2017-10-19T12:33:59Z")

</div>

This Event is not fired all the time; When it listed at MainView.ux -\> it always fires

```auto
push.on("registrationSucceeded", function(regID) {
});

```

---

<div class="post-metadata">

**Author:** ![Uldis](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/uldis/32/657_2.png) [@Uldis](https://forums.fusetools.com/u/Uldis)\
**Post date:** [October 19, 2017, 12:43pm UTC](https://forums.fusetools.com/t/pushnotification-crucial-problem/2222/5 "2017-10-19T12:43:21Z")

</div>

No, it should not _always_ fire. This assumption is wrong. It only fires when the particular device gets a new token from GCM/FCM/APNS.

It is the Apple/Google backend that decides when a new token needs to be issued, and we have no control over that.

---

<div class="post-metadata">

**Author:** ![Ahmed\_Diab](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/ahmed_diab/32/692_2.png) [@Ahmed\_Diab](https://forums.fusetools.com/u/Ahmed_Diab)\
**Post date:** [October 20, 2017, 12:27am UTC](https://forums.fusetools.com/t/pushnotification-crucial-problem/2222/6 "2017-10-20T00:27:05Z")

</div>

Hey Uldis, you didn’t get the error. the error is on the Callback only !  
I have added some lines to detect the problem source and it was from your side because:

1- I have initiate the Push.  
2- The Push notification generates the RegID.  
3- I have print out the RegID.  
4- The library then fires `emit` the event `registrationSucceeded`.  
5- The UX event never fired --\> this is the problem that not all the time i’m getting notified .

---

<div class="post-metadata">

**Author:** ![Uldis](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/uldis/32/657_2.png) [@Uldis](https://forums.fusetools.com/u/Uldis)\
**Post date:** [October 20, 2017, 8:37am UTC](https://forums.fusetools.com/t/pushnotification-crucial-problem/2222/7 "2017-10-20T08:37:17Z")

</div>

You say: `Push notification generates the RegID`. No, it does not. I explained that in my post above.

Until you provide a perfectly clear description of the problem (no, you haven’t), there is nothing else we can do. I’m doing my best to try and understand what you’re reporting, but currently all I see is false expectations.

---

<div class="post-metadata">

**Author:** ![Ahmed\_Diab](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/ahmed_diab/32/692_2.png) [@Ahmed\_Diab](https://forums.fusetools.com/u/Ahmed_Diab)\
**Post date:** [October 20, 2017, 8:42am UTC](https://forums.fusetools.com/t/pushnotification-crucial-problem/2222/8 "2017-10-20T08:42:20Z")

</div>

Bad news 😉 you have to understand me

---

<div class="post-metadata">

**Author:** ![Anders\_Lassen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_lassen/32/522_2.png) [@Anders\_Lassen](https://forums.fusetools.com/u/Anders_Lassen)\
**Post date:** [October 20, 2017, 8:45pm UTC](https://forums.fusetools.com/t/pushnotification-crucial-problem/2222/9 "2017-10-20T20:45:14Z")

</div>

My interpretation of the problem is (after discussing a little with Ahmed on slack):

He is trying to say that when he attaches the `registrationSucceded` handler in the root of `MainView.ux`, then he gets the callback all the time, while if he does so in a different view, it starts to be faulty. This sounds to me like a race condition with the event.

`push.on("registrationSucceeded", function() {...` - if the callback here is registered “too late” then it never gets the memo. The event emitter probably needs to fire on subscription if the registration has already succeded.

But this is not my domain, I’m poking some guys internally to have a closer look.

---

<div class="post-metadata">

**Author:** ![Ahmed\_Diab](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/ahmed_diab/32/692_2.png) [@Ahmed\_Diab](https://forums.fusetools.com/u/Ahmed_Diab)\
**Post date:** [October 20, 2017, 8:48pm UTC](https://forums.fusetools.com/t/pushnotification-crucial-problem/2222/10 "2017-10-20T20:48:01Z")

</div>

Thanks for your assist
