Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70612

Set dev_push programmatically

$
0
0

@axedre wrote:

Hi, I apologize in advance if this has already been asked/answered elsewhere but I couldn't find a similar question on this forum.
I was wondering if there's a way to override, from code, the value of the dev_push property read from .io-config.json.
The reason is: I have ongoing development on my app, I test it mostly in the brower but build it from time to time for testing on my android device. I don't want to have to remember to set dev_push to false before building, and setting it back to true to resume browser development and testing. So I'd like to be able to leave it false (or remove it altogether) and then write something in my controller along the lines of:

var user = {uid: "xxx"};
var register = function() {
    $ionicPush.register({
        canShowAlert: true,
        canSetBadge: true,
        canPlaySound: true,
        canRunActionsOnWake: true,
        onNotification: function(notification) {
            console.info(notification);
        }
    });
};
$ionicUser.identify({
    user_id: user.uid
}).then(function() {
    console.info("Identified user %s", user.uid);
    try {
        register();
    } catch(e) {
        //This happens because we're in browser
        console.warn("Dev_push=false and testing in browser");
        //set dev_push "environment variable" to true, even if it's false
        //on .io-config.json, without persisting it to the json file obviously
        register(); //this time it should behave like when dev_push is set to true
        //and log "$ionicPush:REGISTERED_DEV_MODE DEV-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
    }
});

Does anyone know a way to accomplish this?
Thanks in advance, cheers.

Andy

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70612

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>