Forums

OverviewFelgo 2 Support (Qt 5) › small problem with push notification on iOS

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #20686

    Marek

    Hi

    I have app working on Android and iOS using Onesignal. The problem is that on iOS I can’t see message when app is in foreground. I do receive notification and can see the message when app is in background but when in foreground message is empty.

    Same code is used on Android and iOS. I’m using latest Felgo. iOS is on iPhone 6 version 11.2.6

    Below is debug from iOS and the Android, you can see that there is empty message on iOS (qml] Received notification)

    IOS:
    
    onesignalUserNotificationCenter:willPresentNotification:withCompletionHandler: Fired!
    2018-12-06 11:52:48.268248+0100 omyapp[342:30817] VERBOSE: notificationOpened:isActive called!
    2018-12-06 11:52:48.268591+0100 omyapp[342:30817] [qml] Received notification:  {} true
    2018-12-06 11:52:48.269843+0100 omyapp[342:30817] VERBOSE: network request to: https://onesignal.com/api/v1/notifications/c33c04b2-4093-4d66-b69b-e85874eaedc9
    2018-12-06 11:52:48.270042+0100 omyapp[342:30817] VERBOSE: request.body: {"opened":true,"app_id":"04df708d-2af7-419a-847b-5829999ee399","player_id":"f4a2dc36-5f37-4028-8fa9-41d24a15945e"}
    2018-12-06 11:52:48.273532+0100 omyapp[342:30817] VERBOSE: callLegacyAppDeletegateSelector:withCompletionHandler: Fired!
    2018-12-06 11:52:48.273742+0100 omyapp[342:30817] VERBOSE: oneSignalRemoteSilentNotification:UserInfo:fetchCompletionHandler:
    2018-12-06 11:52:48.273890+0100 omyapp[342:30817] VERBOSE: notificationOpened:isActive called!
    2018-12-06 11:52:48.616476+0100 omyapp[342:31135] VERBOSE: network response: {
        success = 1;
    }
    
    Android:
    D ActivityThread: BDC-Calling onReceive: intent=Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10 pkg=mycompany.myapp cmp=mycompany.myapp/com.onesignal.GcmBroadcastReceiver (has extras) }, receiver=com.onesignal.GcmBroadcastReceiver@92e1047
    V ActivityThread: SVC-Creating service CreateServiceData{token=android.os.BinderProxy@f7cc074 className=net.vplay.plugins.onesignal.OneSignalItem$NotificationExtender packageName=mycompany.myapp intent=null}
    D ActivityThread: SVC-Calling onStartCommand: net.vplay.plugins.onesignal.OneSignalItem$NotificationExtender@879799d, flags=0, startId=1
    D SQLiteDatabase: beginTransaction()
    D SQLiteDatabase: endTransaction()
    D OMyapp: qrc:/qml/Main.qml:221 (expression for onNotificationReceived): qml: Received notification: Activity New activity11 added to object proj7 ob1 in project project7 {} true
    V ActivityThread: SVC-Destroying service net.vplay.plugins.onesignal.OneSignalItem$NotificationExtender@879799d
    D OneSignal: curActivity is NOW: null
    D SurfaceView: 261804773 windowPositionLostRT RT, frameNr = 0
    D OneSignal: onActivityStopped: net.vplay.helper.VPlayActivity
    D OneSignal: curActivity is NOW: null
    D Surface : Surface::disconnect(this=0xd49df500,api=1)
    W IInputConnectionWrapper: beginBatchEdit on inactive InputConnection
    W IInputConnectionWrapper: endBatchEdit on inactive InputConnection
    D QtPositioning: Stopping updates
    D QtPositioning: Stopping updates
    V OneSignal: scheduleLocationUpdateTask:delayMs: 537807
    I OneSignal: GetUnsentActiveTime: 0
    I OneSignal: SaveUnsentActiveTime: 62
    I OneSignal: GetUnsentActiveTime: 62
    D OneSignal: OneSignalRestClient: Making request to: https://onesignal.com/api/v1/players/c564bbbb-9ad1-4c02-a37e-e340b60babd8/on_focus
    D OneSignal: OneSignalRestClient: POST SEND JSON: {"app_id":"04df708d-2af7-419a-847b-5829999ee399","type":1,"state":"ping","active_time":62,"net_type":0}
    I System.out: Check isMmsSendPdu
    I System.out: PDU read len:103
    I System.out: MMS PDU Type:123:34
    I System.out: [OkHttp] sendRequest<<
    V OneSignal: OneSignalRestClient: After con.getResponseCode  to: https://onesignal.com/api/v1/players/c564bbbb-9ad1-4c02-a37e-e340b60babd8/on_focus
    D OneSignal: OneSignalRestClient: Successfully finished request to: https://onesignal.com/api/v1/players/c564bbbb-9ad1-4c02-a37e-e340b60babd8/on_focus
    D OneSignal: POST RECEIVED JSON: {"success":true,"id":"c564bbbb-9ad1-4c02-a37e-e340b60babd8"}

    Code I’m using for Onesignal

    OneSignal {
            id: onesignal
            objectName: "onesignal"
            logLevel: OneSignal.LogLevelVerbose
            appId: Constants.oneSignalAppId
            googleProjectNumber: Constants.oneSignalGoogleProjectNumber
            onNotificationReceived: {
                console.debug("Received notification:", message, JSON.stringify(additionalData), isActive)
                onesignalRect.msg=message
                showOnesignal(true)
                // Possible actions:
                // - Read message from data payload and display a user dialog
                // - Navigate to a specific screen
                // - ...
            }
            onTagsReceived: {
                var tagStr = ""
                for(var tag in tags)
                    tagStr += tag + " = " +tags[tag]
    
                if(tagStr != "")
                    tagStr = "Current tags: "+tagStr
                else
                    tagStr = "Current tags: no tags set"
    
            }
            onUserIdChanged: {
                console.debug("Got OneSignal user id:", userId)
                AppData.setOnesignal(userId)
            }
        }

     

    What can be the problem?

     

    Best,

    Marek

    #20754

    Alex
    Felgo Team

    Hi Marek,

    after a quick look at your issue, it looks like the message title is not forwarded to the app by the OneSignal SDK if the app is active. Can you try adding the message as additionalData to retrieve it in the app?

    Cheers,
    Alex

    #20758

    Marek

    Hi Alex

    Thanks for suggestion, I have placed message in Data and additionalData is visible so I have my message when app is in foreground.

    Best,

    Marek

Viewing 3 posts - 1 through 3 (of 3 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support