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

IOS Push. #117

Open
RodolfoMota opened this issue Apr 6, 2017 · 5 comments
Open

IOS Push. #117

RodolfoMota opened this issue Apr 6, 2017 · 5 comments

Comments

@RodolfoMota
Copy link

Hey, im using xamarin-plugins with firebase.
I'm not getting the push.

That is what I have.

`[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
//

    public override bool FinishedLaunching(UIApplication app, NSDictionary options)
    {
        global::Xamarin.Forms.Forms.Init();
        CachedImageRenderer.Init();
        LoadApplication(new App());
        CarouselViewRenderer.Init();
        //Consider inizializing before application initialization, if using any CrossPushNotification method during application initialization.
        CrossPushNotification.Initialize<CrossPushNotificationListener>();
        //...

        UIUserNotificationType userNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
        UIUserNotificationSettings settings = UIUserNotificationSettings.GetSettingsForTypes(userNotificationTypes, null);
        UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);

        return base.FinishedLaunching(app, options);
    }

    const string TAG = "PushNotification-APN";

    public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
    {


        if (CrossPushNotification.Current is IPushNotificationHandler)
        {
            ((IPushNotificationHandler)CrossPushNotification.Current).OnErrorReceived(error);

        }


    }

    public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
    {
        if (CrossPushNotification.Current is IPushNotificationHandler)
        {
            ((IPushNotificationHandler)CrossPushNotification.Current).OnRegisteredSuccess(deviceToken);

        }

    }

    public override void DidRegisterUserNotificationSettings(UIApplication application, UIUserNotificationSettings notificationSettings)
    {
        application.RegisterForRemoteNotifications();
    }

    //Uncomment if using remote background notifications. To support this background mode, enable the Remote notifications option from the Background modes section of iOS project properties. (You can also enable this support by including the UIBackgroundModes key with the remote-notification value in your app�s Info.plist file.)
    public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
    {
		if (CrossPushNotification.Current is IPushNotificationHandler) 
		{
			((IPushNotificationHandler)CrossPushNotification.Current).OnMessageReceived(userInfo);

		}
    }
    

    public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
    {

        if (CrossPushNotification.Current is IPushNotificationHandler)
        {
            ((IPushNotificationHandler)CrossPushNotification.Current).OnMessageReceived(userInfo);

        }
    }


}`

Console
2017-04-06 17:22:23.828 Rest.iOS[2555:2041400] CrossPushNotification - Token: b8703e9e4e5084270d1f887a4e8d1ff08c245f35531337f8e414d688d [0:] Push Notification - Device Registered - Token : b8703e9e4e5084270d1f887a4e8d1ff08c245f35531337f8e414d688d

@Lkhagvajargal
Copy link

Lkhagvajargal commented Apr 7, 2017

Is anyone know something about this problem? I have same problem.

@carvah
Copy link

carvah commented Apr 7, 2017

I have the same problem... any fix for this? I have every permissions enabled.

@ghost
Copy link

ghost commented Apr 12, 2017

Did you use the Firebase library to convert the APNS token to a Firebase token? You cannot use the APNS token (in your example, b8703e9e4e5084270d1f887a4e8d1ff08c245f35531337f8e414d688d) as-in from your server code.

@AmaralDR
Copy link

AmaralDR commented Apr 19, 2017

@bontibon Do you have any examples of how to convert this TOKEN?

@ghost
Copy link

ghost commented Apr 19, 2017

@AmaralDR I don't, as I decided to implemented separate GCM and APNS logic on my server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants