My Ionic app throws a "has no method 'startInit'" error when using OneSignal - ionic-framework

In my Ionic smart phone app, I'm using OneSignal to handle push notifications. According to some OneSignal docs, I need to initialize their plugin like this:
window.plugins.OneSignal.init(
"b2f7f966-d8cc-11e4-bed1-df8f05be55ba",
{googleProjectNumber: "703322744261"},
notificationOpenedCallback
);
This works for me. But other documentation says I should do this:
window.plugins.OneSignal
.startInit("YOUR_APPID", "YOUR_GOOGLE_PROJECT_NUMBER_IF_ANDROID")
.handleNotificationReceived(function(jsonData) {
alert("Notification received:\n" + JSON.stringify(jsonData));
console.log('Did I receive a notification: ' + JSON.stringify(jsonData));
})
.endInit();
This is what I would prefer to do, since I really want that "handleNotificationReceived" option, not just the "notificationOpenedCallback" option. But it's not working for me. I get a Javascript error saying the method "startInit" doesn't exist in the "window.plugins.OneSignal" object. It's right. There is no method "startInit", so how can I use the code that calls it?
So what am I doing wrong? Am I not using the latest version of OneSignal? I just ran "ionic plugin add onesignal-cordova-plugin --save", so I should be using their latest version. (It installs version ~1.13.2, according to my config.xml).
How can I fix this?

The newer 2.+ version of the SDK is not out yet. You should refer to the old docs for this here
EDIT
The new version of the SDK is now out and you can get it here. Also new docs are here.

Was getting the same issue. You could try reinstalling the plugins or add the platform again android/ios. That worked for me.

Related

Ionic v2 sample with javascript

I could not find a way to start Ionic v2 sample app ionic start appname --v2 with JavaScript and NOT TypeScript.
I have tried --v2 --js, --v2 --no-tsand I always get ts version of app.
Am I wrong or JavaScript version is not available any longer in sample start app?! => ionic-cli.
It seems weird.
Any idea to get it to work? Thank you for your help
Like you can see in this answer:
Just asked in ionic-v2 Slack channel and the answer was:
We're going all in on TS.
You could do your own work and covert it toa es6 workflow, but we want
people to use typescript
As #HerbiShtini mentioned in the comments, in this issue it's said that:
Ionic2 applications are only available as Typescript.

how to show showBusyIndicator into xdk html5 hybrid application?

i added the cordova-notification plugin into intel-xdk appication, when try to show the indicator i get this error:
Uncaught TypeError: Cannot read property 'showBusyIndicator' of undefined
this is the code:
$(document).on("change","#sel_produttori", function(evt)
{
intel.xdk.notification.showBusyIndicator();
});
maybe it is strange the plugin is listed in the first window but not in the second one.
Many of the 'intel.xdk' plugins have been or are being deprecated in favor of their standard core Cordova counterparts. I would recommend using that instead.
The problem you're running into appears to be that you've included the standard Cordova notification plugin, but you're trying to access the intel.xdk notification plugin, which is not included and therefore doesn't exist in your app.
It looks like the corresponding method on the standard Cordova Notification plugin was deprecated some time back and isn't there anymore. You might want to try a plugin like this:
https://github.com/filfat-Studios-AB/cordova-plugin-spinnerdialog
It seems to work for me but, as always, use at your own risk.

Determine Chrome Platform Version

Is there someway to determine the Chrome platform version in order to verify that I can use APIs that are marked v37 and later? If there is an alternative way of verifying that these new parameters are supported by the current install that works as well. My current solution is to check for the existence of a different v37 API which seems to be working, however if there is a sanctioned way that would make me feel a bit better about the whole thing :).
I need to use the 'scopes' portion of this API:
chrome.identity.getAuthToken.
In its Cog Chrome App, François Beaufort is using userAgent with a regex to get the chrome version:
window.alert(
navigator.userAgent.match('Chrome/([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*)')[1]
);
But there is maybe a better way to check if some html/js API are available or not...
Try adding a minimum version to your manifest, so you don't even have to check in your code. This will prevent the app from webstore installs who are on older versions.
"minimum_chrome_version": "37",

Childbrowser with Cordova 1.7 iPhone issue

Can any expert here please point me to some valid walkthrough on how to make the ChildBrowser work with Cordova 1.7 in iPhone? I have found lots of documents and blogs out there that tell you how to do it, but none of them have worked for me. It is not a whitelist issue for sure, as for the time being I have set it to the wildcard *, so whitelisting problems can be safely ruled out I guess. In some cases, ChildBrowser was successfully installed, but when I called the showwebpage function, it just would not show up (there wouldn't be any errors either!). Other times, it just won't even install. I have already spent 2 days on it, and am still clueless. Just hoping if you could help me out. Any help would be appreciated.
I could finally get the ChildBrowser to open up following what Dhawal has suggested below. But the onLocationChange event never seems to fire. Again, this seems to be a common problem with Cordova 1.7. Any workarounds apart from rolling back to some older Cordova version? Any help would be appreciated.
Here's what I am trying to do:
window.plugins.childBrowser.showWebPage(url, { showLocationBar: true });
window.plugins.childBrowser.onLocationChange = function(loc){ alert("In index.html new loc = " + loc); };
Ok, got it to work. Seems like ChildBrowser is still compatible with older versions of Cordova only. Had to delve into Objective-C and make changes in the plugin to make it work.
I have a basic application which has childbrowser integration with Cordova 1.7. I have put the steps also to generate build same application.
ios-cordova-childbrowser
Edit
Childbrowser events were not getting called properly so I added this fix in ChildBrowser.js file to resolve it.
if (cordovaRef && cordovaRef.addConstructor) {
cordovaRef.addConstructor(ChildBrowser.install);
// Make ChildBrowser global
window.ChildBrowser = ChildBrowser;
} else {
console.log("ChildBrowser Cordova Plugin could not be installed.");
return null;
}

issue in openfeint when i call setHighScore function

I am integrating openfient SDK in my app.
When I want to submit user's score and called a function as below it is giving error
'OFDelegate' was not declared in this scope
[OFHighScoreService setHighScore:scores forLeaderboard:#"112033" onSuccess:OFDelegate() onFailure:OFDelegate()];
Please help me to shortout this issue.
This problem may occur when upgrading from an old version of open feint or reading an old post about Open Feint, as this method is no
longer available, yet still compiles and runs.
The following lines will probably be enough to solve this problem:
[OFHighScoreService setHighScore:scores forLeaderboard:#"112033"
onSuccessInvocation:[OFInvocation invocationForTarget:nil selector:nil]
onFailureInvocation:[OFInvocation invocationForTarget:nil selector:nil]];
Just don't forget to import:
#import "OFHighScoreService.h"
Make sure you have integrated OpenFeint SDK with your app. You may find this video useful: http://vimeo.com/5633994