Giter Site home page Giter Site logo

catalystcode / react-native-azurenotificationhub Goto Github PK

View Code? Open in Web Editor NEW
47.0 29.0 72.0 12.37 MB

React Native module to support Azure Notification Hub push notifications on Android, iOS, and Windows.

License: MIT License

Java 54.80% JavaScript 12.49% Objective-C 28.92% C# 3.34% Ruby 0.46%

react-native-azurenotificationhub's Introduction

react-native-azurenotificationhub's People

Contributors

256hz avatar abenzshawel-rsm avatar benvp avatar cpaine-ts avatar dependabot[bot] avatar diegomichell avatar eugnis avatar jbenzshawel avatar jonathanort avatar kant avatar kreativ-software avatar phongcao avatar rozele avatar stephenvisser avatar vishal-techbitsolution avatar yasaricli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-azurenotificationhub's Issues

My Android app gradle build perfectly, but crashes on debug mode

Hi,
My android app crashes as soon as the apk installs and and launches the app.
Neither it is recording any of the crash analytics for the same.

React Native version 0.47.1

adb shell am start -n "com.hm/com.hm.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Client not ready yet..Connected to process 4253 on device samsung-sm_j700f-5203106cfafd5373
Application terminated.

Handling clicking on notification

I am just wondering how I can handle when a user taps on the notification when the application is not open?
I can see that the onRemoteNotification gets run when you tap on a notification while the app is in the foreground. However, if you close the application and tap on a notification, nothing gets run.
How do I handle this?

Thank you!

[iOS] Getting warning "Connection string cannot be null"

I'm unable to register a device after 'Request Permission'. When I click on Register link, I get the following warning in console.

React version:
react-native-cli: 2.0.1
react-native: 0.55.4

Xcode: Version 10.0 (10A255)

Possible Unhandled Promise Rejection (id: 0): Error: Connection string cannot be null. Error: Connection string cannot be null. at createErrorFromErrorData (blob:http://192.168.1.236:8081/fed0ac8f-27c4-4eaf-b822-2a7023cbfe08:2054:17) at blob:http://192.168.1.236:8081/fed0ac8f-27c4-4eaf-b822-2a7023cbfe08:2006:27 at MessageQueue.__invokeCallback (blob:http://192.168.1.236:8081/fed0ac8f-27c4-4eaf-b822-2a7023cbfe08:2448:18) at blob:http://192.168.1.236:8081/fed0ac8f-27c4-4eaf-b822-2a7023cbfe08:2193:18 at MessageQueue.__guardSafe (blob:http://192.168.1.236:8081/fed0ac8f-27c4-4eaf-b822-2a7023cbfe08:2361:11) at MessageQueue.invokeCallbackAndReturnFlushedQueue (blob:http://192.168.1.236:8081/fed0ac8f-27c4-4eaf-b822-2a7023cbfe08:2192:14) at http://192.168.1.236:8081/debugger-ui/debuggerWorker.js:70:58

android not working

react-native-azurenotificationhub/android/src/main/java/com/azure/reactnative/notificationhub/ReactNativeNotificationHubPackage.java:19: error: method does not override or implement a method from a supertype
@OverRide
^
1 error
:react-native-azurenotificationhub:compileReleaseJavaWithJavac FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-azurenotificationhub:compileReleaseJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Android not receiving notifications

Hello,

I am successfully getting notifications through iOS, and used to get them through Android. Until recently.

Wondering if "GCM is deprecated #63" issue is affecting me?

I am testing with Azure "Test Send" with particular id targeted, but never see the notifications pop up. Nothing on adb log... just dead silence with the installation instructions provided.

What I am asking: Is there a way to trouble shoot the react-receiver side without doing something like "https://docs.microsoft.com/en-us/azure/notification-hubs/notification-hubs-android-push-notification-google-fcm-get-started" and cluttering up my pristine .58 react install (I don't want to build classes in Android Studio)...

Any ideas would be welcome.

Initial Setup Questions - Might need to wait for NPM

Hey @rozele. This might not be the best way to ping you on this, but figured it was better than Discord.

I spent time integrating Azure into the project, to get familiar. Works great. So I moved on to your module. Downloaded and dropped the code in node_modules. Your JS seem straightforward. I added the config file to same directory as my JS. I added the csproj to my sln and added a reference to it. All of this works.

I'm hitting issues with this error....
"Requiring unknown module "./config"

So I commented it out and just added the variables in the main JS. But I still cant successfully run. Now I'm getting a weird error. I've confirmed RN packager is running.

Exception thrown: 'System.Runtime.InteropServices.COMException' in mscorlib.ni.dll
WinRT information: A connection with the server could not be established

Thanks again for this. If this works out, "thank you" truly wouldn't come close to how appreciative I would/will be of all your help.

`fbjs/lib/invariant` does not exist in the Haste module map

I'm getting the error below on iOS. Any idea what might have happened? I tried clearing my cache.

error: bundling failed: Error: Unable to resolve module fbjs/lib/invariant from /Users/x/Documents/Source/app/node_modules/react-native-azurenotificationhub/ios/AzureNotificationHubIOS.js: Module fbjs/lib/invariant does not exist in the Haste module map

GCM is deprecated

So, the underlying code of this library uses gcm, which as per google has been deprecated and will stop working from 29th May'19.
FirebaseInstanceId.getInstance().getToken();, android studio also suggests that getToken() is deprecated.
Just wanted to understand here, will this affect my application after 29thMay once GCM stops working ?
Are there any plans to migrate this library to completely FCM ?

Your response will be highly appreciated

Publish new npm version

Can someone publish a new npm version with the updates to the google services in the gradle file? I'm changing it locally, but when others pull it down they have to change it as well. This is related to #53 and #56.

Thanks!

targetSdkVersion should be set to 22

All dependencies seem to have targetSdkVersion <= 20 so 22 should be good enough and it's also consistent with the template project generated by react-native.

Build failed

hello, I am getting an error in this way on android,

> Task :react-native-azurenotificationhub:compileDebugJavaWithJavac FAILED
/Users/Y/Desktop/mobile/node_modules/react-native-azurenotificationhub/android/src/main/java/com/azure/reactnative/notificationhub/ReactNativeNotificationsHandler.java:117: error: constructor Builder in class Builder cannot be applied to given types;
            NotificationCompat.Builder notification = new NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID)

react-native: 0.57.0

ext config

screen shot 2018-10-03 at 12 32 43

remoteNotificationReceived event not firing on foreground

I followed the android example installation, and it registers correctly and receives the notification correctly while the app is in killed state or on background. but while on foreground nothing seems to fire.

this is an example of the code I'm using:

import React, { Component } from 'react'
import {
  View,
  Alert,
  Image,
  TouchableOpacity,
  ImageBackground,
  Linking,
  AsyncStorage,
  StatusBar,
  Dimensions,
  NativeEventEmitter
} from 'react-native'


//-----------
const NotificationHub = require('react-native-azurenotificationhub');
const PushNotificationEmitter = new NativeEventEmitter(NotificationHub);

const NOTIF_REGISTER_AZURE_HUB_EVENT = 'azureNotificationHubRegistered';
const NOTIF_AZURE_HUB_REGISTRATION_ERROR_EVENT = 'azureNotificationHubRegistrationError';
const DEVICE_NOTIF_EVENT = 'remoteNotificationReceived';

const connectionString = '*****; // The Notification Hub connection string
const hubName = '*****';          // The Notification Hub name
const senderID = '*****';         // The Sender ID from the Cloud Messaging tab of the Firebase console
const tags = ['test'];           // The set of tags to subscribe to
//-----------

export default class LoginView extends Component {
  constructor(props) {
    super(props)
    PushNotificationEmitter.addListener(DEVICE_NOTIF_EVENT, this._onRemoteNotification);
  }

  register() {
    PushNotificationEmitter.addListener(NOTIF_REGISTER_AZURE_HUB_EVENT, this._onAzureNotificationHubRegistered);
    PushNotificationEmitter.addListener(NOTIF_AZURE_HUB_REGISTRATION_ERROR_EVENT, this._onAzureNotificationHubRegistrationError);

    NotificationHub.register({connectionString, hubName, senderID, tags})
      .catch(reason => console.warn(reason));
  }


  render() {
    this.register();
    return (
      <View>
        Example
      </View>
    )
  }
  _onAzureNotificationHubRegistered(registrationID) {
    console.warn('RegistrationID: ' + registrationID);
  }

  _onAzureNotificationHubRegistrationError(error) {
    console.warn('Error: ' + error);
  }

  _onRemoteNotification(notification) {
    console.warn('Notification received: ' + notification);
  }
}

Thanks!

Notification handler for android

I need a way to navigate to a specific page when a user selects the notification. I am able to do this with the notification handler built for IOS but not android. Is there a simple way to accomplish this with the existing version of the library?

[Android] Add registration success/failed event

When a registration is successful or fails, the JavaScript module should be notified. Currrently, Android does registration on an IntentService, so we'll need a broadcast of some kind to let the foreground module know what registration ID / failure cause was.

Device Registration is not happening

Hi I implemented all the steps provided in the tutorial. However the register method does not seem to work. It does not throw any error either

I don't see the device in the notification hub registered devices list. I tried sending a test push notifcation from azure portal without any tag and with tag I used in the app. It says "Message was successfully sent, but there were no matching targets".

Please advise

Android is not working

Hello,
I created a new blank project with react-native init asd then I added your lib. with npm install react-native-azurenotificationhub then I made settings with your documentation. Finally I wrote react-native run-android in console. Result is : Build Failed.

ekran resmi 2019-02-22 11 48 28

code is below:

`Hasan-MacBook-Pro:asd hasanrizauzuner$ react-native run-android
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...

Configure project :app
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (28.0.2) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.2.1.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '28.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

Configure project :react-native-azurenotificationhub
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (26.0.3) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.2.1.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '26.0.3'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

Task :app:processDebugManifest FAILED
/Users/hasanrizauzuner/Desktop/asd/android/app/src/main/AndroidManifest.xml:16:7-34 Error:
Attribute application@allowBackup value=(false) from AndroidManifest.xml:16:7-34
is also present at [com.microsoft.azure:azure-notifications-handler:1.0.1] AndroidManifest.xml:12:9-35 value=(true).
Suggestion: add 'tools:replace="android:allowBackup"' to element at AndroidManifest.xml:9:5-40:19 to override.

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:processDebugManifest'.

Manifest merger failed : Attribute application@allowBackup value=(false) from AndroidManifest.xml:16:7-34
is also present at [com.microsoft.azure:azure-notifications-handler:1.0.1] AndroidManifest.xml:12:9-35 value=(true).
Suggestion: add 'tools:replace="android:allowBackup"' to element at AndroidManifest.xml:9:5-40:19 to override.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUİLD FAILED in 1s
16 actionable tasks: 1 executed, 15 up-to-date
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html

Command failed: ./gradlew installDebug

Error: Command failed: ./gradlew installDebug
at checkExecSyncError (child_process.js:621:11)
at Object.execFileSync (child_process.js:639:13)
at runOnAllDevices (/Users/hasanrizauzuner/Desktop/asd/node_modules/react-native/local-cli/runAndroid/runAndroid.js:299:19)
at buildAndRun (/Users/hasanrizauzuner/Desktop/asd/node_modules/react-native/local-cli/runAndroid/runAndroid.js:135:12)
at isPackagerRunning.then.result (/Users/hasanrizauzuner/Desktop/asd/node_modules/react-native/local-cli/runAndroid/runAndroid.js:65:12)
at process.internalTickCallback (internal/process/next_tick.js:77:7)`

Android Marshmallow Integration issue

Is this module functioning for android 6. I tried to install followed all the instructions .Build was successful but no registrations happened.Moreover there is no way to confirm that registration was successful. No error was thrown stating the same.

Add notification event for foreground apps

When a notification occurs while the app is in the foreground, a native event should be dispatched so JavaScript behavior can be added (e.g., Alert, Toast for Android, etc.)

Update Getting Started

Should the Android Installation section of Getting Started be updated to match new dependencies for version 0.6.0 of this lib?

From Getting Started:
Screen Shot 2019-04-02 at 1 51 58 PM

[iOS] Private headers causes Archive to fail

Hi.

First of all thank you for bringing this functionality to react native.

I found an issue when trying to archive my iOS application after linking this library.
The WindowsAzureMessaging target has private headers.

screen shot 2018-05-23 at 14 11 18

This causes xcode to archive the project as a generic archive instead of as an iOS app since the private headers are not copied to the application.

The workaround is to copy all the headers from private to project.

screen shot 2018-05-23 at 14 22 05

FCM token null after NotificationHub.unregister()

After unregistering with Azure and trying to register again, FirebaseInstanceId.getInstance().getToken() is returning a null token. Is this expected behavior?

The conditional statement in the code below is failing because the hub is trying to register with a null token from the token refresh.

This line throws an exception:
regID = hub.register(token, tags).getRegistrationId();

String token = FirebaseInstanceId.getInstance().getToken();
Log.d(TAG, "FCM Registration Token: " + token);

// Storing the registration ID indicates whether the generated token has been
// sent to your server. If it is not stored, send the token to your server.
// Also check if the token has been compromised and needs refreshing.
if (regID == null || storedToken != token) {
NotificationHub hub = new NotificationHub(hubName, connectionString, this);
Log.d(TAG, "NH Registration refreshing with token : " + token);
regID = hub.register(token, tags).getRegistrationId();
Log.d(TAG, "New NH Registration Successfully - RegId : " + regID);
notificationHubUtil.setRegistrationID(this, regID);
notificationHubUtil.setFCMToken(this, token);
}

Register dosen't happen

After Register is initiated from mobile nothing happens i have put logs at

Intent intent = new Intent(reactContext, ReactNativeRegistrationIntentService.class); reactContext.startService(intent); NotificationsManager.handleNotifications(reactContext, senderID, ReactNativeNotificationsHandler.class);

i have put a log there This was excuting after that I could not figure out whats happening

I have checked in cloud explorer where my registered device list is visible

I didnt see any devices there

Pls help me :)

Issue with iOS registration (Unauthorized)

Getting an error "Unauthorized" for the token. Also the API version is specified as 2013-04 whereas the latest version is 2015-01.

Is the SharedAccessSignature token generation logic is changed from the API version?

deviceToken in react native

Any can give some smart solution for read device Token's ?

In iOS implementation for react native we need use
var remoteNotificationsDeviceToken = ''
where is that token ?

Pls any direction, help, solution

xcodebuild commands fail

I can create the xcarchive of my project just fine but when trying to sign the app the xcodebuild command fails. I can do these commands just fine without this package but once it is added those commands fail. I have tried manually linking the package multiple times in case I did something wrong with that but it still fails.

This runs just fine every time:

xcodebuild -workspace ios/MyProject.xcworkspace -quiet -scheme MyProject -configuration Release archive -archivePath MyProject.xcarchive -allowProvisioningUpdates

This command fails when package is added:

xcodebuild -exportArchive -archivePath MyProject.xcarchive -exportPath ./ -exportOptionsPlist ios/exportOptions.plist

2018-06-28 08:01:54.557 xcodebuild[68198:6959279] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/zx/9tr49ycd3j9fjds4pw_5pp7m0000gq/T/MyProject_2018-06-28_08-01-54.556.xcdistributionlogs'.
error: exportArchive: exportOptionsPlist error for key 'method': expected one of {}, but found enterprise

Error Domain=IDEFoundationErrorDomain Code=1 "exportOptionsPlist error for key 'method': expected one of {}, but found enterprise" UserInfo={NSLocalizedDescription=exportOptionsPlist error for key 'method': expected one of {}, but found enterprise}

** EXPORT FAILED **

Android build fails on RN 0.47+

Android build is failing with the following error:
...\ReactNativeNotificationHubPackage.java:19: error: method does not override or implement a method from a supertype

Looks like the createJSModules() override was removed in 0.47.

Device not getting registered with Azure on Android

Hey guys. Thanks for the hard work on this, it couldn't have come at a better time. All good on Windows (thank you!) and now implementing on Android. I followed the installation guide, app builds, no JS errors, double-checked everything looks good. Connection strings match Win and iOS, which all register perfectly.

But I'm not getting my device registered in the Azure notification hub (viewing registered devices in the portal) and my generic test messages are obviously not sending either.

Any gotchas not mentioned in the install guide I should look into? I'm using @0.1.0, [email protected], targetSDKVersion: 22, buildToolsVersion: 23

Thanks!

UPDATE: Here is the error in the logs. I must be missing a simple setup issue somewhere. Which is odd, because I'm using Firebase as my DB and authentication for this app, without issue.

10-04 07:44:01.716 23209-23672/com.arriver E/AzureNotificationHub: Failed to complete token refresh
java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist. 
at com.google.firebase.FirebaseApp.getInstance(Unknown Source)
at com.google.firebase.FirebaseApp.getInstance(Unknown Source)
at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source)
at com.azure.reactnative.notificationhub.ReactNativeRegistrationIntentService.onHandleIntent(ReactNativeRegistrationIntentService.java:37)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.os.HandlerThread.run(HandlerThread.java:61)

Build fails on Android

After following Android guide and trying to build the application the build process fails with:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApk'.
   > A problem occurred configuring project ':react-native-azurenotificationhub'.
      > The SDK Build Tools revision (23.0.1) is too low for project ':react-native-azurenotificationhub'. Minimum required is 25.0.0

Could be user error...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.