OneSignal in Ionic V1 with Android SDK 31+ - android

I'm having problems with my old application built on Ionic V1. From now on we need to use SDK 31 or higher on Android. I made the adjustments in my application but I am not able to make OneSignal work.
Plugin installed: onesignal-cordova-plugin 2.11.3
My app.js:
`
$ionicPlatform.ready(function() {
var notificationOpenedCallback = function(jsonData) {
var data = jsonData.notification.payload.additionalData;
if (data && data.targetUrl) {
if (data.paramsValue) {
$state.go(data.targetUrl, { paramID : data.paramsValue } );
}else{
$state.go(data.targetUrl);
}
}
//alert("Notification opened:\n" + JSON.stringify(jsonData));
console.log('notificationOpenedCallback: ' + JSON.stringify(jsonData));
};
// TODO: Update with your OneSignal AppId before running.
window.plugins.OneSignal
.startInit("MY_ID_ONESIGNAL")
.handleNotificationOpened(notificationOpenedCallback)
.endInit();
window.plugins.OneSignal.getIds(function(ids) {
$localStorage.pushToken = ids.userId;
$rootScope.pushToken = ids.userId;
//alert("player id: " + ids.userId);
});
window.plugins.OneSignal.getPermissionSubscriptionState(function(status) {
idapp = status.subscriptionStatus.userId;
});
`
I tried to update the OneSignal cordova plugin to the latest version but it still doesn't work, it's likely that the app.js needs to be changed.

Related

OneTrust flutter sdk only works on android

i'm trying to integrate the OneTrust sdk in my flutter app, but on ios devices doesn't work.
I'm using the following package:
https://pub.dev/packages/onetrust_publishers_native_cmp/versions/6.25.0
As mentioned in the documentation of the package, the package installed version is the same version in the OneTrust template published through the dashboard on OneTrust site, then I add this line in my Podfile platform :ios, '11.0'.
This is the init function
Future<void> initOneTrust(bool mounted) async {
bool status = false;
log("Init onetrust start");
try {
//Params are not required
final String domainIdentifier = Platform.isAndroid
? OneTrustConfig.domainIdentifierAndroid
: OneTrustConfig.domainIdentifierIos;
// Map<String, String> params = {"countryCode": 'IT', "regionCode": 'IT'};
status = await OTPublishersNativeSDK.startSDK(
storageLocation,
domainIdentifier, // Dynamic identifier
// 'dec6b152-4ad9-487b-8e5a-24a06298417f', // ONETRUST README DEBUG IDENTIFIER
'it',
// params,
);
log("STATUS: $status");
} on PlatformException {
print("Error communicating with platform-side code");
}
if (!mounted) return;
setState(() {
_cmpDownloadStatus = status.toString();
});
}
}
The function above is called in the initState
#override
void initState() {
super.initState();
initOneTrust(mounted)
.then((value) => {OTPublishersNativeSDK.showBannerUI()});
}
The banner show without any problems only on android devices with API 29. I can't find any compatibility documentation between the android api and sdk.
On ios the function always return false and no error logs appears.
Some details:
OneTrust SDK Version: 6.25.7
Flutter 2.10.4

Expo-google-app-auth gives error while signing in

I'm making an app in react native and really need to add google auth. But I can't get it to work. It shows an error: ExpoAppAuth.Get Auth: Encountered exception when trying to start auth request: null
Code
My Sign-In function
signInAsync = async () => {
try {
const conf = {
androidClientId: config.google_client_id,
}
let result = await Google.logInAsync(conf);
if (result.type === 'success') {
console.log(result.accessToken);
this.props.navigation.navigate('dashboard');
} else {
return { cancelled: true };
}
} catch (e) {
console.error(e.message);
return { error: true };
}
};
Versions
windows 10.0.19043.1466
node.js v16.13.1
npm 8.1.2
expo-google-app-auth ~9.0.0
expo 5.0.3
Android studio Arctic Fox 2020.3.1
Emulator Pixel 5 api 30
Android 11.0

How can I solve this cordova media capture error?

I'm trying to register a video in my application through the cordova plugin Media Capture. According to the documentation, this is my code :
startRegistration(){
var captureSuccess = function(mediaFiles) {
var i, path, len;
for (i = 0, len = mediaFiles.length; i < len; i += 1) {
path = mediaFiles[i].fullPath;
// do something interesting with the file
}
};
// capture error callback
var captureError = function(error) {
};
navigator.device.capture.captureVideo(captureSuccess, captureError, {limit:1});
}
I tried compiling the code but I received the following error :
Property 'device' does not exist on type 'Navigator'
What is going wrong?
Its used to work like this in Ionic 1 but not anymore. Now you will need to install #ionic-native/media-capture as well.
Skip first command if you already have latest plugin installed.
ionic cordova plugin add cordova-plugin-media-capture
npm install #ionic-native/media-capture
After installing you can use this plugin like this
import { MediaCapture, MediaFile, CaptureError, CaptureImageOptions } from '#ionic-native/media-capture/ngx';
constructor(private mediaCapture: MediaCapture) { }
...
let options: CaptureImageOptions = { limit: 3 }
this.mediaCapture.captureImage(options)
.then(
(data: MediaFile[]) => console.log(data),
(err: CaptureError) => console.error(err)
);
Here is the link where you can find details
Corodva or Capacitor Please follow accordingly. You can find guides for both in this link.

ionic configuring push notifications

I'm trying to setup push notifications, I'm stuck here, and I have no idea where to put this code:
const cloudSettings: CloudSettings = {
'core': {
'app_id': 'APP_ID',
},
'push': {
'sender_id': 'SENDER_ID',
'pluginConfig': {
'ios': {
'badge': true,
'sound': true
},
'android': {
'iconColor': '#343434'
}
}
}
};
P.s app.modules.ts doesn't exist in my project
Ionic version: 2.1.4
Cordova: 6.4.0
Try this
http://tphangout.com/ionic-2-push-notifications/
Or you can try wiht OneSignal Push Notfications, they have great documentation...

Ionic 2 push payload - How to use payload in component

I'm sending a push notification with Firebase and it works. When I send a payload with the push notification how is possible to read the data from the payload in the component.
When I alert the msg object from the observable it alerts [object, Object]
const cloudSettings: CloudSettings = {
'core': {
'app_id': 'fec59dd8'
},
'push': {
'sender_id': '808269516661',
'pluginConfig': {
'ios': {
'badge': true,
'sound': true
},
'android': {
'iconColor': '#343434',
'senderID': '808269516661'
}
}
}
};
Here is the code that subscribes to the push notification
this.push.rx.notification()
.subscribe((msg) => {
alert(msg.title + ': ' + msg.text);
if (msg.app.asleep || msg.app.closed) {
// The app is being opened from a notification
alert("OPEN APP");
alert(msg);
this.rootPage = RetailPage;
} else {
// The app was already open when the notification was received
alert("APP WAS OPEN");
}
});
}
Your system information:
ordova CLI: 6.3.1
Ionic Framework Version: 2.0.0-rc.3
Ionic CLI Version: 2.1.12
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.46
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v6.7.0
Xcode version: Not installed
Any help appreciated
Best regards

Categories

Resources