Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26437] Ti.Network.registerForPushNotifications callback not working when application resume.

GitHub Issuen/a
TypeBug
PriorityCritical
StatusResolved
ResolutionDuplicate
Resolution Date2018-10-05T04:01:05.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsios, ios-12, sdk-7.4.0.GA
ReporterSathaphorn Kerdmalai
AssigneeVijay Singh
Created2018-09-25T09:14:57.000+0000
Updated2018-10-05T08:22:30.000+0000

Description

Ti.Network.registerForPushNotifications callback not working when application resume.
Ti.App.iOS.addEventListener('usernotificationsettings', function registerForPush() {
			// Remove event listener once registered for push notifications
			Ti.App.iOS.removeEventListener('usernotificationsettings', registerForPush);

			Ti.Network.registerForPushNotifications({
				success : deviceTokenSuccess,
				error : deviceTokenError,
				callback : receivePush
			});
		});
it's working find when application was killed but when application resume and got notification, Open application from notifcation center receivcePush not call.

Attachments

FileDateSize
ScreenRecording_09-28-2018 08-37-14 (1).m4v2018-09-28T01:42:38.000+00004245017

Comments

  1. Rakhi Mitro 2018-09-25

    Hello, Thanks for sharing this. Can you share full test code to reproduce the issue on our end? Also share your complete environment details.
  2. Sathaphorn Kerdmalai 2018-09-25

       if (parseInt(Ti.Platform.version.split(".")[0]) >= 8) {
       
       		// Wait for user settings to be registered before registering for push notifications
       		Ti.App.iOS.addEventListener('usernotificationsettings', function registerForPush() {
       			// Remove event listener once registered for push notifications
       			Ti.App.iOS.removeEventListener('usernotificationsettings', registerForPush);
       
       			Ti.Network.registerForPushNotifications({
       				success : deviceTokenSuccess,
       				error : deviceTokenError,
       				callback : receivePush
       			});
       		});
       
       		// Register notification types to use
       		Ti.App.iOS.registerUserNotificationSettings({
       			types : [Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT, Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND, Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE]
       		});
       	}
       
    Here is code when i register push notification.
       function receivePush(e) {
          var inBackground = e.inBackground;
         alert('receivePush ' + JSON.stringify(e));
        }
       
    I tested when i killed app will alert when open app from notfication center. after that i send push message again its just only open app but not alert data from push notification.
  3. Sathaphorn Kerdmalai 2018-09-27

    Do you have any ideas?. I think on ios12 apple changed how to handle push notification when the application in the foreground.
  4. Rakhi Mitro 2018-09-27

    [~iblack.dum], Thanks for your feedback. Can you send us a screenshot which displays the issue ?
  5. Sathaphorn Kerdmalai 2018-09-27

    I'll send to you but I think we have to use
       - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
       }
       - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(nonnull UNNotificationResponse *)response withCompletionHandler:(nonnull void (^)(void))completionHandler {
       }
       
    to handler push notification when an application on the foreground.
  6. Sharif AbuDarda 2018-09-27

    Hello [~iblack.dum], What's the update of your issue. Does that fix your issue? Send us screenshot which displays the issue. Thanks.
  7. Sathaphorn Kerdmalai 2018-09-28

    [^ScreenRecording_09-28-2018 08-37-14 (1).m4v] See step from a video. Step 1: Application does not open yet send a push notification will open an application alert data from a push. Step 2: Application on background, and send a push notification will open an application but receviePush function not called. Step 3: Application on a foreground, and send a push notification. It still displays a notification on the notification center.
  8. Sathaphorn Kerdmalai 2018-10-02

    Hi Sharif, Do you have any ideas? How to fix it?
  9. Vijay Singh 2018-10-04

    [~iblack.dum] Can you please verify your issue using sdk 7.4.1 as several notification issues have been fixed in TIMOB-26399? You can get 7.4.1 sdk directly via CLI - appc ti sdk install -b 7_4_X Thanks!
  10. Sathaphorn Kerdmalai 2018-10-04

    Yes, it's work perfectly. What's time will you release this version officially.
  11. Vijay Singh 2018-10-05

    [~iblack.dum]Thanks for confirming. We are running one iOS 12 issue TIMOB-26391. As soon as it get fixed, we will go for release. Thanks!
  12. Sathaphorn Kerdmalai 2018-10-05

    I got this issue too. Random freeze some view. Ti SDK 7.2.0 . if I use SDK 7.1.0 this issue will resolve.

JSON Source