Open aminvb12 opened 5 years ago
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;
@Husseinhj Do you mean this ?
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.
@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"
}
}
]
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 setsound
key with a valid value. by defaultsound
value isdefault
.
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 thedevice type
.
@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.
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.
@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
Are you calling any SDK methods in your app's background thread @aminvb12 ?
@behrad No
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.
@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');
// });
}
We will go through your code and test it @aminvb12
However I see some strange points in your code:
Why are you appending apple
prefix to your userIds? Chabok handles platform segmentation for you
Why are you subscribing to USER channel? chabok already does this for you automatically
You are adding USER tag! why?
You also don't need to store USERID, chabok handles that. And that's not secure to store it plain text by application
@aminvb12 Did you update the Chabok to the last version (v1.0.0)?
@aminvb12 آیا مشکل شما حل شده است؟
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.