iOS Question Push notifications, when app is terminated

Semen Matusovskiy

Well-Known Member
Licensed User
Hi, guys --

In my app remote notifications work fine in foreground and background. But, if app is terminated, there are no Application_RemoteNotification events.
I found old forum discussions and accepted this situation like inevitable evil.

But an application of my son's company accepts pushes, even if terminated.
Unf., my son is a web-developer and does not know details. Alone, what is known, that they use ordinary (not silent) pushes.

How ? Any ideas ?
 

Brandsum

Well-Known Member
Licensed User
In iOS if an app is suspended or terminate then push notifications will be handled by system. But if you want to handle a push notification even if your app is terminated then you have to add NotificationServiceExtention. But it is not supported by B4I. Though if you know objective c and have xcode knowledge then you can add that from xcode.
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
Though if you know objective c and have xcode knowledge then you can add that from xcode.

I hoped that this is more easy :) My XCode knowledge is zero.

But a problem is very typical, so maybe somebody already fixed this.
 
Upvote 0

Brandsum

Well-Known Member
Licensed User
Yes in xcode its easy. But the app group setup process is a bit complicated. I have done this before but every time you build a release version you need to do all those stuff again. Thats why I had to remove notification handling stuff from my project. So how you can do that is as follows,

1. You need a Mac and Local Builder
2. Build Release version.
3. Open local builder folder in you mac
4. Go to UploadedProjects > UserName
5. Open B4iproject.xcodeproj
6. Now there are lots of tutorials of NotificationServiceExtention available on internet
7. Follow those steps
8. Dont forgot to setup app group from apple developer console
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
The purpose of NotificationServiceExtention is to customize the notification.

Yes, this is a direct purpose. But, as I understand some comments on stackoverflow, a fact that this extention is present , changes IOS behaviour.
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
I tried to implement dummy NotificationServerExtention.

XCode creates three files (see XCode.zip).
To convert .m and .h was simple (hope, I did this correctly - see 2.zip).

But when I tried to add #PlistExtra : <key>NSExtension</key>..., the screen became back (Activity_Start happens and dies).
Guess, OBJC code is not important here (the same happens, if to remove inline objective-c).

I suspect that IOS tries to communicate with app using service functions and does not receive correct answer.

Any ideas ?
 

Attachments

  • xcode.zip
    1.5 KB · Views: 107
  • test.zip
    1.3 KB · Views: 121
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
Unf., I did not follow any tutorial. I simply added "target" in XCode.

BTW, I was not able to reproduce your algorithm (from step 6). The wizard offered to enter "ProductName" and to change Bundle.
But if you can add NotificationServerExtention to B4I-project, we can compare original and modified variants and will find differences.
 
Upvote 0

Brandsum

Well-Known Member
Licensed User
The wizard offered to enter "ProductName" and to change Bundle.
Yes after adding the target to your project you need a different provision profile for your extension. You have to create it from apple developer console and you have to turn on push notification capability and configure apn then the extension will work. That's why I told you to search for an example on the internet.
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
I see problems :)

It seems that the extensions are organized separately from the project itself. Like in Windows - Exe and Dll.
So my attempt to include objc into main module was wrong.
 
Upvote 0
Top