Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app will crash while on receiving notification #8

Open
aminvb12 opened this issue Aug 30, 2018 · 15 comments
Open

app will crash while on receiving notification #8

aminvb12 opened this issue Aug 30, 2018 · 15 comments

Comments

@aminvb12
Copy link

Hi first of all thanks for your support.
My react-native app will crash & also freeze, sometimes while receiving notification but there is no error on xcode or react-native console ,just show :
#11 0x000000010277162c in -[RCTEventEmitter sendEventWithName:body:] at /projectPath/projectName/node_modules/react-native/React/Modules/RCTEventEmitter.m:39
and :
Thread 1: signal SIGABRT.

I will be thankful from your team if you answer my issue.

@Husseinhj
Copy link
Contributor

Could you give us your notification payload? It helps us to find out what is the problem.
For enabling the Chabok framework logs, Put this code in your iOS AppDelegate.m class.

[PushClientManager defaultManager].enableLog = YES;

@aminvb12
Copy link
Author

@Husseinhj Do you mean this ?
screen shot 1397-06-08 at 18 06 18 2

@Husseinhj
Copy link
Contributor

It's hard to find the exact notification payload.
Did you send the notification with the Chabok panel or API?

If using the API so give me the notification payload here to see this or using the Chabok panel give me the JSON of data in push message.

@aminvb12
Copy link
Author

aminvb12 commented Aug 30, 2018

@Husseinhj
I'm using sandbox api,
here you are the payload :

[{
  "user": "apple09176062135",
  "content": "test",
  "inApp": false,
  "live": false,
  "useAsAlert": true,
  "alertText": "test",
  "notification": {
    "title": "test",
    "body": "test1",
    "sound": "string"
  }
}
]

@Husseinhj
Copy link
Contributor

Husseinhj commented Aug 31, 2018

I think your app crashed when reloading the JS. This was only happening on Reload.
If it's true I'll fix the iOS bridge in a new version.

NOTE: In your payload set sound key with a valid value. by default sound value is default.

NOTE: The Chabok platform by default get device type for sending a push notification with segmentation so you don't need to start your userId with the device type.

@aminvb12
Copy link
Author

@Husseinhj no!not only happening on Reload .
This was happening meantime using an application.
I mean sometimes i received notification , this will happen for me.

@Husseinhj
Copy link
Contributor

Husseinhj commented Aug 31, 2018

I mean sometimes i received notification

If you give me the scenario it helps me to fix this.
But you can update AdpPushClient.h file in node_module to this :

#import "React/RCTBridgeModule.h"
#import "React/RCTEventEmitter.h"

@interface AdpPushClient : RCTEventEmitter <RCTBridgeModule,RCTInvalidating>

@end

Test with this change.

@aminvb12
Copy link
Author

@Husseinhj
Every time the application crash , after the application carsh i will see this :
../node_modules/react-native-chabok/ios/AdpPushClient.m: runtime: UI API called from background thread: -[UIApplication registerUserNotificationSettings:] must be used from main thread only

@behrad
Copy link
Contributor

behrad commented Aug 31, 2018

Are you calling any SDK methods in your app's background thread @aminvb12 ?

@aminvb12
Copy link
Author

@behrad No

@behrad
Copy link
Contributor

behrad commented Aug 31, 2018

This error shows that Chabok methods may have been called from background threads.

@aminvb12 Please give some details or a simulation of your code path (sample of how are you calling chabok methods) so that we can re-generate this.

And that method is not related to receiving notification. Make sure you are giving us correct details.

@aminvb12
Copy link
Author

aminvb12 commented Aug 31, 2018

@behrad
Here is my javascript code we are calling to receive notification from chabok and we were checking user parameter not to be null.

init_chabok_notification = async()=>{
        const options = {
            "appId": "*************************",
            "apiKey": "/*/*/*/*",
            "username": "****",
            "password": "&&&&&",
            "isDev": true
        };

        let USER = await AsyncStorage.getItem('user');

        if(!USER){
            return
        }
        USER = 'apple'+JSON.parse(USER).username;
        // let phone = ;
        var channels = ["adv", "news" , USER ];
        this.chabok = new chabok.AdpPushClient();

        this.chabok.initializeApp('ashawash', options , (response) => {

        });


        const chabokEmitter = new NativeEventEmitter(NativeModules.AdpPushClient);

        chabokEmitter.addListener(
            'connectionStatus',
            (status) => {
                console.log('connectionStatus', status)
            }
        );

        chabokEmitter.addListener(
            'ChabokMessageReceived',
            (message) => {
                console.log("\nChabok Message Received :", message);
            }
        );
        this.chabok.register(USER, channels);
        this.chabok.addTag(USER)

// // subscribe to channel
//         this.chabok.subscribe(channels[0]).then(res => () => {
//             console.log(res);
//             alert('subscribe success');
//         });
    }

@behrad
Copy link
Contributor

behrad commented Aug 31, 2018

We will go through your code and test it @aminvb12

However I see some strange points in your code:

  1. Why are you appending apple prefix to your userIds? Chabok handles platform segmentation for you

  2. Why are you subscribing to USER channel? chabok already does this for you automatically

  3. You are adding USER tag! why?

  4. You also don't need to store USERID, chabok handles that. And that's not secure to store it plain text by application

@Husseinhj
Copy link
Contributor

Husseinhj commented Sep 24, 2018

@aminvb12 Did you update the Chabok to the last version (v1.0.0)?

@Husseinhj
Copy link
Contributor

@aminvb12 آیا مشکل شما حل شده است؟

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants