One signal integration with react native - react-native-ios

I'm working on integrating One-Signal with react native,
I followed One-Signal Docs.
now when I try to build on my iOS simulator I recieve this error:
OneSignal-inAppMessageClicked is not a supported event type for
RCTOneSignalEventEmitter. Supported events are: OneSignal-
remoteNotificationReceived, OneSignal-remoteNotificationOpened,
OneSignal-idsAvailable, OneSignal-emailSubscription
On the actual device everything seems to work.
My package.json:
"dependencies": {
"react": "16.8.3",
"react-native": "^0.59.9",
"react-native-onesignal": "^3.3.0",
}

This was a bug in the SDK that has since been fixed.

I'm getting these errors even with new versions of SDK:
2022-03-03 08:48:11.130
[error][tid:com.facebook.react.OneSignalQueue][RCTEventEmitter.m:78]
OneSignal-inAppMessageWillDisplay is not a supported event type for
RCTOneSignalEventEmitter. Supported events are:
...
[error][tid:com.facebook.react.OneSignalQueue][RCTEventEmitter.m:78]
OneSignal-inAppMessageWillDismiss is not a supported event type for
...
[error][tid:com.facebook.react.OneSignalQueue][RCTEventEmitter.m:78]
OneSignal-inAppMessageDidDismiss is not a supported event type for
RCTOneSignalEventEmitter. Supported events are:
...
[error][tid:com.facebook.react.OneSignalQueue][RCTEventEmitter.m:78]
OneSignal-inAppMessageDidDisplay is not a supported event type for
RCTOneSignalEventEmitter. Supported events are:
OneSignal-permissionChanged, OneSignal-subscriptionChanged,
OneSignal-notificationWillShowInForeground,
OneSignal-remoteNotificationOpened, OneSignal-inAppMessageClicked,
OneSignal-emailSubscriptionChanged,
OneSignal-smsSubscriptionChanged
I have the current version installed:
"react": "17.0.2",
"react-native": "0.62.2",
"react-native-onesignal": "^4.3.7",
Is there any way to workarround these errors?

Related

TypeError: Right-hand side of 'instanceof' is not an object (mongoose error)

I'm using these versions: "mongodb": "^3.6.3", "mongoose": "^5.10.18" and I'm having an issue where sometimes when I do a mongo SomeModel.create() in a cron job, it fails because of this error:
TypeError: Right-hand side of 'instanceof' is not an object and it fails on the node_modules/mongoose line in the screenshot below. This used to work completely fine and one day it just started happening without me changing the package versions or any other related code.
I see that I could revert back to a mongoose version like 3.9 that doesn't include the code in this screenshot but it still confuses me how this started to be flaky one day whereas it used to work perfectly fine on the same versions.
Here is roughly how I write my .create()
await Repayment.create({
userId: user._id,
isAutopay: true
});
Any ideas on how I can fix? Thanks!
screenshot is here

Alternative for Deprecated NSKeyedUnarchiver.UnarchiveTopLevelObject in Xamarin IOS

I'm creating a .Net MAUI app, and since I need to render higher number of points to the UI, I'm going platform native to render.
I'm new to IOS, and for performance efficient renderings I have referred the sample given in this blog, where I'm decoding the existing layer and copying to a new CAShapeLayer. But I'm facing deprecated warning for these below changes.
var newDrawingLayer = NSKeyedUnarchiver.UnarchiveTopLevelObject(
data: NSKeyedArchiver.GetArchivedData(drawingLayer, false, out error), error: out error) as CAShapeLayer;
What would be the alternative to achieve this in Xamarin IOS?.
Finally I have solved myself. Instead using deprecated UnarchiveTopLevelObject we can use GetUnArchiveObject and additional parameter need to be given which represents type of object to get. Here I'm getting from CAShapeLyer, you can give as object.Class(here it is drawingLayer.Class). The following code solves my problem.
var newDrawingLayer = NSKeyedUnarchiver.GetUnArchiveObject(drawingLayer.Class,
data: NSKeyedArchiver.GetArchivedData(drawingLayer, false, out error), error: out error) as CAShapeLayer;

Use multivocal libary to configure repeat intent in Dialogflow for VUI

I'm trying to configure my VUI to repeat a sentence in Dialogflow when it is prompted for this. Little back story, I am helping develop a social robot for elderly so repeating a sentence is a much needed feature. I just started on this project and the previous developer responsible for this is gone and not reachable, also, I have no experience in Node.js.
I am looking to use the multivocal for this. These are the steps I have done so far:
Created an intent called 'Repeat'.
Added training phrases for the intent
Added 'multivocal.repeat' as an action
Enabled webhook call for this intent
In Node.js added 'intentMap.set('Repeat', repeat);' to my existing intentMap
// Run the proper function handler based on the matched Dialogflow intent name
let intentMap = new Map();
intentMap.set('Game_Rock_Paper_Scissors - Result', game_stone_paper_scissors);
intentMap.set('Game_Rock_Paper_Scissors - Result - yes', game_stone_paper_scissors_again);
intentMap.set('Conversation tree', conversation_tree);
intentMap.set('Question date', question_date);
intentMap.set('Question time', question_time);
intentMap.set('Music', music);
intentMap.set('Repeat', repeat);
Next, under the 'Fulfillment' tab, I want to enter the function inside the Inline Editor 'index.js' tab and make sure in the 'package.json' that the multivocal library is installed and usable. So far, there are a few things in my package.json
"name": "dialogflowFirebaseFulfillment",
"description": "This is the default fulfillment for a Dialogflow agents using Cloud Functions for Firebase",
"version": "0.0.1",
"private": true,
"license": "Apache Version 2.0",
"author": "Google Inc.",
"engines": {
"node": "8"
},
"scripts": {
"start": "firebase serve --only functions:dialogflowFirebaseFulfillment",
"deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment"
},
"dependencies": {
"actions-on-google": "^2.2.0",
"firebase-admin": "^5.13.1",
"firebase-functions": "^2.0.2",
"dialogflow": "^0.6.0",
"dialogflow-fulfillment": "^0.5.0"
}
}
So, how do I install the library? In the Read.me is says 'You can install it using npm install --save multivocal.' But where would I install this? Do I put this somewhere in the index.js or packages.js?
Also, in this example it shows the index.js code to be:
const Color = require('./color.js');
Color.init();
const Multivocal = require('multivocal');
exports.webhook = Multivocal.processFirebaseWebhook;
Should I just add this to the end of my index.js? Or should it be wrapped in a function? Sorry to be so not experienced in this but I hope I explained it clearly.
Some answers for using multivocal using the Dialogflow Inline Editor:
How do I include this in the package.json file?
The directions for using npm are if you're writing the fulfillment locally and not using the Editor.
You need to add this line in the dependencies section:
"multivocal": "^0.14.0"
and Dialogflow / Firebase Cloud Functions will take care of importing the library. You won't need the "actions-on-google", "dialogflow", or "dialogflow-fulfillment" libraries, so the section can look something like this:
"dependencies": {
"firebase-admin": "^5.13.1",
"firebase-functions": "^2.0.2",
"multivocal": "^0.14.0"
}
How do I write my index.js?
The simple example assumes that you can put your configuration and code in a separate file ("color.js" in the example). Since you can't do that with the Inline Editor, the general boilerplate of your code will be something like this:
// Import the library on the first line, so you can call methods on it to setup your configuration
const Multivocal = require('multivocal');
// Your configuration and code go here
// Setup the webhook as the final line
exports.dialogflowFirebaseFulfillment = Multivocal.processFirebaseWebhook;
Where do the Intent Handler registration and functions go?
Unlike the dialogflow-fulfillment library, multivocal doesn't use an explicit intentMap. It maintains one itself, so to register an Intent Handler function you would use something like
Multivocal.addIntentHandler( intentName, handlerFunction );
BUT keep in mind that handler functions are also a little different.
What? How are they different?
Multivocal has a lot of things handled through configuration, rather than code. So there is no direct counterpart to the agent.add() function call that you'd have with dialogflow-fulfillment or the actions-on-google library.
Instead, your Intent Handler function should perform any logic, database calls, or whatever to get values that will be used in responses and save them in the Environment. Every Handler should return a Promise that contains the Environment.
You should also set configuration for your Intent - the most common of which is to set the possible "Response" templates. The most simple response templates just include text, and where to insert values from the environment. It is also best practice to prompt the user for what they can do next, so we might setup a "Suffix" template to use by default, or one to use for specific Intents, Actions, or Outents.
So if you had an Intent named "color.favorite", and had a value in the environment called "color" (that your handler may have loaded from a database), the configuration for this response in English may look something like this. It also includes a default suffix to prompt the user what they can do next.
const config = {
Local: {
en: {
Response: {
"Intent.color.favorite": [
"{{color}} is one of my favorite colors as well.",
"Oh yes, {{color}} can be quite striking.",
"I can certainly understand why you like {{color}}."
]
},
Suffix: {
Default: [
"What other color do you like?"
"Tell me another color."
]
}
}
}
}
and you would register this configuration with
new Multivocal.Config.Simple( config );
You can (and are expected to) register multiple configurations, although you can combine them in one object. So the Response section above could contain response sections for each of your Intents, by name.
Ok, but how do I handle a "repeat" Intent?
All you need to do is provide an Intent that has its "Action" set to "multivocal.repeat" in the Dialogflow UI and that has the webhook enabled. So something like this would work:
Multivocal already has registered a handler and configuration based on this.
If you want to change the possible responses, you can add configuration for the "multivocal.repeat" Action. Which may look something like this:
const enRepeat = [
"Sorry about that, let me try again.",
"I said:"
];
const config = {
Local: {
en: {
Response: {
"Action.multivocal.repeat": enRepeat
}
}
}
}
and then either combine this configuration with other configurations you've written, or load it as above.
To emphasize - there is no need for you to write any code for this, just some optional configuration.

webdriverio 5.16 browser.element is not a function

i have a problem after i upgraded webdriver from 4.8 to 5.16:
My package.json
"#wdio/cli": "^5.16.15",
"#wdio/local-runner": "^5.16.15",
"#wdio/mocha-framework": "^5.16.15",
"#wdio/spec-reporter": "^5.16.11",
"#wdio/sync": "^5.16.15",
...
"chromedriver": "^79.0.0",
...
"selenium-webdriver": "3.0.0-beta-2",
....
"wdio-chromedriver-service": "^5.0.2",
"webdriverio": "^5.16.15",
then in my test i call:
browser.element('body')
result error:
browser.element is not a function
Was this function replaced (didn't find any notes about that)? and if so, whats the function to use now?
Or is there another problem? Help pls.
if I understand your question correctly, browser.element() is no longer available in v5.
As per their official changelog, it is changed to browser.findElement in v5.
You can also use browser.$() in place of browser.element().
Here is the complete list of changes in v5 if you have not figured it out yet.
https://github.com/webdriverio/webdriverio/blob/master/CHANGELOG.md#v500-2018-12-20
browser.elements(...) no longer exists in v5.x - https://github.com/webdriverio/webdriverio/blob/master/CHANGELOG.md#boom-breaking-change-1
Just use
const elem = $('body')
to find first element, or
const divs = $$('div')
to find all elements, and get them in array.
If you are trying to get an array of the elements then you need
browser.elements('body') // plural
for single element just use
$('body')
Hope I got the idea right

How to be absolutely sure that socket.io is working?

Normally, in order to know that it's started, there's a message in Node that says "info - socket.io started". However, for some reason, I'm not getting it. Could be a version thing.
So is there another way to know if my socket is up and listening?
Have you recently updated Socket.io from version 0.9 to 1.x? The default values for log reporting changed with version 1.0, and it's less verbose by default.
See the upgrade documentation.
PS: If you upgraded Socket.io and you didn't even realize it, then it's because your "package.json" file does not lock versions. I'd strongly advise AGAINST using * as version: always be more specific, locking the versions at least to the minor version (as per semver). For example:
// In package.json, under "dependencies":
// NOT SAFE: this always gets the last version, which may have some breaking change (as per semver, with version X.Y.Z, changes in X allow breaking changes in APIs)
"socket.io": "*"
// POSSIBLY SAFE: this does not update to the new major version, so API compatibility *should* be always maintained (however, it's not 100% safe too, to be used carefully)
"socket.io": "1.x"
// SAFE: this allows updates that contain bug fixes and minor additions; API-compatibility should always be guaranteed
"socket.io": "1.0.x"
"socket.io": "1.0.*" // equivalent
"socket.io": "~1.0.4" // equivalent

Resources