Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Notification Observers (iOS) and Broadcast Receivers (Android) #473

Closed
hamorphis opened this issue Jul 23, 2015 · 4 comments

Comments

@hamorphis
Copy link
Contributor

iOS

// Add the notification observer
if (app.ios) {
    app.ios.addNotificationObserver(UIDeviceBatteryLevelDidChangeNotification,
        function onReceiveCallback(notification: NSNotification) {
            var percent = UIDevice.currentDevice().batteryLevel * 100;
            var message = "Battery: " + percent + "%";
            console.log(message);
        });
}
// When no longer needed, remove the notification observer
if (app.ios) {
    app.ios.removeNotificationObserver(UIDeviceBatteryLevelDidChangeNotification);
}

Android

//Register the broadcast receiver
if (app.android) {
    app.android.registerBroadcastReceiver(android.content.Intent.ACTION_BATTERY_CHANGED,
        function onReceiveCallback(context: android.content.Context, intent: android.content.Intent) {
            var level = intent.getIntExtra(android.os.BatteryManager.EXTRA_LEVEL, -1);
            var scale = intent.getIntExtra(android.os.BatteryManager.EXTRA_SCALE, -1);
            var percent = (level / scale) * 100.0;
            console.log("Battery: " + percent + "%");
        });
}
// When no longer needed, unregister the broadcast receiver
if (app.android) {
    app.android.unregisterBroadcastReceiver(android.content.Intent.ACTION_BATTERY_CHANGED);
}
@hamorphis hamorphis self-assigned this Jul 23, 2015
@hamorphis hamorphis added this to the 1.3.0 milestone Jul 23, 2015
hamorphis added a commit that referenced this issue Jul 23, 2015
Resolved Issue #473: Add support for Notification Observers (iOS) and Broadcast Receivers (Android)
@hamorphis hamorphis added ready for test TSC needs to test this and confirm against live production apps and automated test suites and removed in progress labels Jul 24, 2015
hamorphis added a commit that referenced this issue Jul 27, 2015
Resolved Issue #473: Add support for Notification Observers (iOS) and Broadcast Receivers (Android)
@hamorphis hamorphis added done and removed ready for test TSC needs to test this and confirm against live production apps and automated test suites labels Jul 31, 2015
@hamorphis hamorphis reopened this Aug 5, 2015
@hamorphis hamorphis added in progress and removed done labels Aug 5, 2015
@hamorphis
Copy link
Contributor Author

  • Add support for multiple notification observers for the same notification in iOS.

@deepak4u2006
Copy link

Correct me If I am wrong, there is no option of creating Broadcast for iOS/android.
(PostNotification/ SendBroadCast). Is there any plan to add this feature?

@carlosdelfino
Copy link

carlosdelfino commented Oct 6, 2017

I am not succeeding in using the Broadcasting register, I tried as in the gist below and have no feedback whatsoever.
What am I doing wrong?

https://gist.github.com/carlosdelfino/2c12684f5e46f3bd9f40d732f03a78d9

@lock
Copy link

lock bot commented Aug 27, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Aug 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants